erosson / swarm-numberformat

Format large numbers in several human-readable ways. Designed for incremental games like swarmsim.
https://erosson.github.io/swarm-numberformat/
MIT License
89 stars 10 forks source link

maybe sigfigs shouldn't round below `minSuffix` #17

Open erosson opened 7 years ago

erosson commented 7 years ago

This is confusing behavior:

new numberformat.Formatter({flavor: 'short',format: 'standard'}).format(1004)
// => "1,000"

it's because flavor: 'short' applies sigfigs: 3, which rounds 1004 -> 1000. This is bad behavior though, sigfigs is useful for controlling the length of the number-string, this gives less precision without reducing the length. minSuffix already applies special behavior here, so changing its sigfigs behavior isn't really a stretch.

from https://www.reddit.com/message/messages/8famth