Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New metric prefixes #350

Closed
0xflotus opened this issue Dec 5, 2022 · 7 comments · Fixed by #389
Closed

New metric prefixes #350

0xflotus opened this issue Dec 5, 2022 · 7 comments · Fixed by #389

Comments

@0xflotus
Copy link

0xflotus commented Dec 5, 2022

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
Copy link
Owner

sharkdp commented Dec 5, 2022

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):

prefixDict Dictionary (DerivedUnit DerivedUnit)
prefixDict = Dictionary
[ Q.kibi ==> ["kibi", "Ki"]
, Q.mebi ==> ["mebi", "Mi"]
, Q.gibi ==> ["gibi", "Gi"]
, Q.tebi ==> ["tebi", "Ti"]
, Q.pebi ==> ["pebi", "Pi"]
, Q.exbi ==> ["exbi", "Ei"]
, Q.zebi ==> ["zebi", "Zi"]
, Q.yobi ==> ["yobi", "Yi"]
, Q.atto ==> ["atto", "a"]
, Q.femto ==> ["femto", "f"]
-- peta and mega have to be up here (before pico and milli) in order for the
-- prefixes ('p' and 'm') not to be parsed as 'pico' or 'milli'.
, Q.peta ==> ["peta"]
, Q.mega ==> ["mega"]
, Q.pico ==> ["pico", "p"]
, Q.nano ==> ["nano", "n"]
, Q.micro ==> [ "micro"
, "u" -- u for micro
, "µ" -- Micro sign U+00B5
, "μ" -- Greek small letter mu U+039C
]
, Q.milli ==> ["milli", "m"]
, Q.centi ==> ["centi", "c"]
, Q.deci ==> ["deci", "d"]
, Q.hecto ==> ["hecto", "h"]
, Q.kilo ==> ["kilo", "k"]
, Q.mega ==> ["M"]
, Q.giga ==> ["giga", "G"]
, Q.tera ==> ["tera", "T"]
, Q.peta ==> ["P"]
, Q.exa ==> ["exa", "E"]
]

@0xflotus
Copy link
Author

0xflotus commented Dec 5, 2022

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):

prefixDict Dictionary (DerivedUnit DerivedUnit)
prefixDict = Dictionary
[ Q.kibi ==> ["kibi", "Ki"]
, Q.mebi ==> ["mebi", "Mi"]
, Q.gibi ==> ["gibi", "Gi"]
, Q.tebi ==> ["tebi", "Ti"]
, Q.pebi ==> ["pebi", "Pi"]
, Q.exbi ==> ["exbi", "Ei"]
, Q.zebi ==> ["zebi", "Zi"]
, Q.yobi ==> ["yobi", "Yi"]
, Q.atto ==> ["atto", "a"]
, Q.femto ==> ["femto", "f"]
-- peta and mega have to be up here (before pico and milli) in order for the
-- prefixes ('p' and 'm') not to be parsed as 'pico' or 'milli'.
, Q.peta ==> ["peta"]
, Q.mega ==> ["mega"]
, Q.pico ==> ["pico", "p"]
, Q.nano ==> ["nano", "n"]
, Q.micro ==> [ "micro"
, "u" -- u for micro
, "µ" -- Micro sign U+00B5
, "μ" -- Greek small letter mu U+039C
]
, Q.milli ==> ["milli", "m"]
, Q.centi ==> ["centi", "c"]
, Q.deci ==> ["deci", "d"]
, Q.hecto ==> ["hecto", "h"]
, Q.kilo ==> ["kilo", "k"]
, Q.mega ==> ["M"]
, Q.giga ==> ["giga", "G"]
, Q.tera ==> ["tera", "T"]
, Q.peta ==> ["P"]
, Q.exa ==> ["exa", "E"]
]

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
Copy link
Collaborator

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

@sharkdp
Copy link
Owner

sharkdp commented Dec 27, 2022

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
Copy link
Collaborator

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
Copy link
Owner

sharkdp commented Dec 28, 2022

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

@triallax triallax added this to the v5.9.0 milestone Dec 28, 2022
@sadmoonphoenix
Copy link

sadmoonphoenix commented May 23, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants