We use ICU4J to implement text number pattern, and that library
implements the UTS #35 specification:

https://unicode.org/reports/tr35/tr35-numbers.html#Number_Format_Patterns

That describes the pattern for scientific notation as being an E
followed by one or more zeros, so that spec is where the requirement
comes from--you must have at least one zero following the E, and there
can be no hashes.

I'm not positive for the technical reason, but I can make a guess.

Keep in mind that the # pattern means any digit, but to omit leading and
trailing zeros.

With that in mind, as an example, say we wanted to represent 100 in
scientific notation. That would be 1 x 10^2, or 1E2.

Note that we can put as many zeros in front of the 2 without changing
the value. For example, 1E002 still has the value of 100.

Also note that we cannot add any trailing zeros or it changes the
number. For example, 1E20 is 1x10^20, which is a massive number.

So really, the only thing you can change in the exponent part is the
minimum number of exponent digits you want, and those digits will be
left-padded with zeros if needed. And that's exactly what the number of
zeros after the E in the pattern specify--the minimum number of zeros.

If you want no padding, then you specify one zero, e.g. 0E0. If you want
at least two digits, then 0E00, etc. Using hashes wouldn't provide any
extra information, and could potentially be confusing. So I suspect
that's why the spec only allows 0's.

I guess one place where 0E0 could potentially be different than 0E#
would be if you wanted the exponent to be optional if it were 0. So
instead of 1E0 you might want 1E. But that's not common notation, so
likely why they didn't bother supporting it.

- Steve



On 4/9/21 12:27 PM, Roger L Costello wrote:
> Hi Folks,
> 
> My input is this exponential number:
> 
>       3E2
> 
> I have found that these are valid values for textNumberPattern:
> 
>       #E0
>       0E0
> 
> But this is invalid:
> 
>       #E#
> 
> That seems odd to me. Why is that invalid? After all, both # and 0 mean digit 
> (0-9), right?
> 
> /Roger
> 

Reply via email to