globalize icon indicating copy to clipboard operation
globalize copied to clipboard

Number formatting with ”d” code – needs explanation & example fix

Open yucca42 opened this issue 15 years ago • 2 comments

The description of ”d” number formatting code as ”for decimal digits” sounds very odd. It seems that the format code ”d” really means using the non-localized JavaScript number format, just with left-padding the string with zeros to get a minimum width specified by number after the format character ”d”.

So Globalize.format( 123.45, "d" ) yields 123.45 (not 123 as currently in the documentation). Maybe the documentation is meant to use 123 as the first parameter, on the grounds that the ”d” format is really meant for integers only, isn’t it? Moreover, it should perhaps be emphasized that the result is not localized, e.g. Globalize.format( 1234, "d") yields 1234 independently of locale, not a localized presentation with a thousands separator (1,234 or 1 234 or something like that).

yucca42 avatar Jun 21 '11 12:06 yucca42

Sorry for typo in the heading, I meant ”d” (as in my text), not ”n”.

yucca42 avatar Jun 21 '11 12:06 yucca42

Duplicate of #42

rdworth avatar Jun 21 '11 12:06 rdworth