swarm-numberformat icon indicating copy to clipboard operation
swarm-numberformat copied to clipboard

Rounds small values to 0

Open fuzzything44 opened this issue 7 years ago • 2 comments

Sometimes I want to introduce something that gets produced at a low rate like .1/s. If I use this to format 0.1, it just rounds it to 0, ignoring sigfigs.

fuzzything44 avatar Oct 03 '17 20:10 fuzzything44

This may be relevant

https://en.wikipedia.org/wiki/Names_of_small_numbers

Essentially they are the same names but with the -th suffix e.g. 1e−6 -> Millionth.

angarg12 avatar Oct 04 '17 12:10 angarg12

Overlooked this, sorry for the delay.

Use maxSmall when you might have small numbers to avoid rounding. Here's a unit test to demonstrate: https://github.com/erosson/swarm-numberformat/commit/dd3d32ab155f79c5055138a1ab73a7c9ea9f6d04

Thousandth, millionth, etc: No need for this in my projects, so I'm not planning to add it anytime soon. Happy to take pull requests, though!

erosson avatar Dec 04 '17 17:12 erosson