[Unicode]   Common Locale Data Repository : Bug Tracking Home | Site Map | Search
 
Modify

CLDR Ticket #5815(closed enhancement: fixed)

Opened 2 years ago

Last modified 16 months ago

1.2E45 is nothing humans should see

Reported by: mark Owned by: jchye
Component: main Data Locale:
Phase: Review: mark
Weeks: Data Xpath:
Xref:

ticket:4715

Description

We have gotten requests for scientific formats that people (as opposed to programmers) can reasonably expect.

Here is some sample code to generate formats, but it really needs to be based on data. I suggest an alternate symbol, something like:

<superscriptingExponent>×10<superscriptingExponent>

Workaround Code:

    public static DecimalFormat getSuperFormat(ULocale locale) {
        DecimalFormat baseFormat = (DecimalFormat) NumberFormat.getScientificInstance(locale);
        DecimalFormatSymbols symbols = baseFormat.getDecimalFormatSymbols();
        char[] digits = symbols.getDigits();
        symbols.setExponentSeparator("×" + digits[1] + digits[0] + "<sup>");
        baseFormat.setDecimalFormatSymbols(symbols);
        baseFormat.setNegativeSuffix("</sup>" + baseFormat.getNegativeSuffix());
        baseFormat.setPositiveSuffix("</sup>" + baseFormat.getPositiveSuffix());
        return baseFormat;
    }
    
    public static void main(String[] args) {
        for (ULocale locale : NumberFormat.getAvailableULocales()) {
            if (!locale.getCountry().isEmpty()) { // just to cut down the number of examples
                continue;
            }
            DecimalFormat snf = getSuperFormat(locale);
            String formatted = snf.format(-1.23456E-23);
            System.out.println("<tr><td>" + locale + "</td><td>" + locale.getDisplayName(ULocale.ENGLISH) + "</td><td>" + formatted + "</td></tr>");
        }
    }

Note that for Latn digits, we also have the option of using the Unicode characters.

Attached is a screenshot.

Attachments

Screen Shot 2013-03-18 at 9.15.39.png (22.4 KB) - added by mark 2 years ago.

Change History

Changed 2 years ago by mark

comment:1 follow-up: ↓ 4 Changed 2 years ago by richard.wordingham@…

Unicode does not support general super- and subscripting in plain text, and using the superscript European digits would be a bad precedent - can we guarantee that others won't then demand them?

comment:2 Changed 2 years ago by emmons

  • Status changed from new to assigned
  • Component changed from unknown to data
  • Priority changed from assess to major
  • Milestone changed from UNSCH to 24dsub
  • Owner changed from anybody to jchye
  • Type changed from unknown to enhancement

comment:3 Changed 2 years ago by pedberg

  • Cc pedberg added
  • Xref set to 4715

cldrbug 4715: was resolved as a duplicate of this.

comment:4 in reply to: ↑ 1 Changed 2 years ago by mark

Replying to richard.wordingham@…:

Unicode does not support general super- and subscripting in plain text, and using the superscript European digits would be a bad precedent - can we guarantee that others won't then demand them?

Supplying this extra field just means enables implementations to provide superscripting exponents.

This would normally be done with markup.

In the special case of Latin digits, an implementation could also use the superscript Unicode characters.

U+207B ( ⁻ ) SUPERSCRIPT MINUS
U+2070 ( ⁰ ) SUPERSCRIPT ZERO
U+00B9 ( ¹ ) SUPERSCRIPT ONE
U+00B2 ( ² ) SUPERSCRIPT TWO
U+00B3 ( ³ ) SUPERSCRIPT THREE
U+2074 ( ⁴ ) SUPERSCRIPT FOUR
U+2075 ( ⁵ ) SUPERSCRIPT FIVE
U+2076 ( ⁶ ) SUPERSCRIPT SIX
U+2077 ( ⁷ ) SUPERSCRIPT SEVEN
U+2078 ( ⁸ ) SUPERSCRIPT EIGHT
U+2079 ( ⁹ ) SUPERSCRIPT NINE

Just because an implementation could do that doesn't mean that we shouldn't offer the symbol for implementations that would use markup.

comment:5 Changed 2 years ago by jchye

  • Review set to mark

comment:6 Changed 2 years ago by mark

  • Status changed from assigned to closed
  • Resolution set to fixed

comment:7 Changed 16 months ago by emmons

  • Milestone 24dsub deleted

Milestone 24dsub deleted

View

Add a comment

Modify Ticket

Action
as closed
The ticket will be disowned. The resolution will be deleted. Next status will be 'new'
Next status will be 'closed'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.