icu4x
icu4x copied to clipboard
Finish compact decimal formatting
We have formatting from integers. We need to add it from general FixedDecmial & f64 and add support for currencies.
Note that there are two places where floating point numbers are rounded: first in the conversion of the floating point number to the shortest decimal string, and second when performing the user-visible rounding logic.
Discussion about double rounding:
- @sffc - Double-rounding is specified here in EMCA-402. In ECMAScript, a way to rationalize this is that floating point numbers are seen as compact representations of decimal numbers, so this operation is simply a function in the 1:1 mapping.
- @eggrobin - In the general case, that rationalization is not applicable. But, in the case of number formatting in ICU4X, this is a definite edge case. We could say that we can change the behavior here in the future if desired. I don't want to tie ourselves to the ECMA double rounding standard.
Consensus: For now, implement compact rounding with the ECMA-style double rounding, but leave open the door to do it differently in the future.
LGTM: @eggrobin @sffc @skius @younies