numbro icon indicating copy to clipboard operation
numbro copied to clipboard

Support for SI units?

Open klyngbaek opened this issue 9 years ago • 5 comments

I would like to add another another format with the letter 'k' (similar to 'a') to indicate something should be formatted with si prefixes.

Example:

numeral(0.0000032434).format('0.0 k');
// 3.2 μ

numeral(0.0000032434).format('0.[00] k');
// 3.24 μ

I want to get some feedback to see if this makes sense to implement. If it does, I'll submit a pull request.

Thanks in advance.

klyngbaek avatar Dec 16 '15 16:12 klyngbaek

+1

clemmy avatar Dec 16 '15 18:12 clemmy

Sounds like it can't hurt :smile:

why the k?

BenjaminVanRyseghem avatar Dec 17 '15 09:12 BenjaminVanRyseghem

It's just the SI prefix for kilo -- we could use si or something else if you prefer. What do you think?

klyngbaek avatar Dec 17 '15 15:12 klyngbaek

ok.

the code as to be a single character

BenjaminVanRyseghem avatar Dec 18 '15 12:12 BenjaminVanRyseghem

That sounds great (but the fact it's from 2015 doesn't make me hopeful :cry:)

I was looking into expressing units such as "Gbps" (gigabits per second) and "Mpps" (megapackets per second). The bytes formatting in the code handles units like MB/MiB, but seems hardcoded to express bytes, rather than any other types of units, as far as I could tell.

Perhaps another way to frame this bug is to generalize that support, and provide two types of unit prefixes, SI and IEC/IEEE?

paravoid avatar Oct 19 '20 11:10 paravoid