sharkdp / insect

High precision scientific calculator with support for physical units
https://numbat.dev/
MIT License
3.18k stars 126 forks source link

New metric prefixes #350

Closed 0xflotus closed 1 year ago

0xflotus commented 1 year ago

The Wikipedia site of the metric prefixes shows new unit prefixes:

Name Symbol Base 10
quetta Q 1e30
ronna R 1e27
ronto r 1e-27
quecto q 1e-30

It was adopted by BIPM in 2022

With insect I can add two datasizes like Petabyte and Terabyte.

2 PB + 1 TB = 2.001 PB

But it is not possible to add a Quettabyte and an Exabyte.

Please implement the new metric prefixes to allow this.

sharkdp commented 1 year ago

Sounds good. Note that we have a slightly more complete set for binary prefixes, if you're mostly interested in data sizesa. They go up to up to yobi (YiB):

https://github.com/sharkdp/insect/blob/75443006d910ab5680921266db917986fc12561c/src/Insect/Parser.purs#L157-L190

0xflotus commented 1 year ago

Sounds good. Note that we have a slightly more complete set for binary prefixes, if you're mostly interested in data sizesa. They go up to up to yobi (YiB):

https://github.com/sharkdp/insect/blob/75443006d910ab5680921266db917986fc12561c/src/Insect/Parser.purs#L157-L190

Are zetta, yotta, yocto and zepto also missing?

It's not possible to convert 1e21 m to Zm.

1e21 m -> Zm  1e+21 m ➞ Zm  Unknown identifier: Zm

triallax commented 1 year ago

@sharkdp do we want to have this in our next release?

sharkdp commented 1 year ago

I would hope it could be an easy thing to add. Unless this creates new "conflicts". Like for example, if <new SI prefix>+<existing unit that takes an SI prefix>==<name of other existing unit>. We wouldn't expect any such conflicts within SI, of course. But maybe with one of the non-standard units that we also support. Examples for a clash from the past: f(femto)+t(ton)==ft(feet).

triallax commented 1 year ago

Hmm, I'm not motivated enough to check for conflicts at the moment, so I'm leaving it for later (or for somebody else :P), unless you want to work on it of course.

sharkdp commented 1 year ago

If course. I don't think we need to manually check for conflicts. I think we have parametrized tests in place that make sure that units with prefixes are properly parsed

signalno11 commented 1 year ago

is there any reason P and M aren't defined for peta and mega? From what I can tell, the parser is in fact case sensitive.

Ignore me, I just saw that they are defined separately, probably for parsing reasons.