-
Notifications
You must be signed in to change notification settings - Fork 858
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
Suggestion: Add support for SI and IEC binary number suffixes #427
Comments
If this suggestion is adopted, I would also suggest allowing uppercase K (in addition to lowercase k) for 1000. Although uppercase K is not an official SI unit, if uppercase K is not allowed then it will cause confusion. All the other suffixes follow the pattern "remove the lowercase i from the binary suffix and you get the decimal suffix". If Ki -> K is allowed, then that pattern holds at all times and there will be less user confusion in the long run. |
Also, the |
I really like this as an addition to TOML, particularly since it would be very useful in memory/disk configuration examples. I don't think these are made irrelevant by the scientific notation addition to TOML, particularly the IEC Binary Numbers. The SI/IEC prefixes are useful in some circumstances where it is conventional to use SI/IEC labeling. Scientific notation is useful in cases where it is not conventional to use SI notation. This is particularly relevant for large numbers. In academic applications something like For example: disk_size = 512Mi
distance_to_datacentre = 10K
number_of_stars_in_the_milky_way = 2.5e11 One very big advantage of implementing these would be that configuration files would no longer have to choose an appropriate scaling to their values. For example, it is common to see configuration files using keys like In short, prefix notation allows numbers in config files to be actual numbers, not some scaled version of them in order to achieve reasonable human-writable values. I would also suggest using I think anyone messing around with configuration files would intuitively be able to understand the syntax without having to refer to TOML documentation. |
What we're doing with these units is not applying dimensions to numbers, but rather keeping them dimensionless and multiplying them. So @JeppeKlitgaard I'm inclined to agree with you that uppercase |
With all due respect to @rmunn, there's a problem with choosing how to turn floats with binary units into integers. What would be most useful? Using trunc, floor, ceiling (which is what I'd personally expect if I was using Let's keep it simple. Integers with units will be integers, and floats with units will be floats. Let the application figure out how to turn |
There could be a minor conflict using For the sake of faster adoption, could we just start with everything from We could add the E, Z, and Y units later on if there continues to be a demand. But for now at least, floats with exponents would be preferable in real-life scenarios past the penta level, wouldn't they? |
I agree that the use-cases for exa- and above is limited/non-existent at the moment, though I think it would be better to do this addition in just one version of TOML. Parsers are anyway going to need to support the other suffices, so ensuring that exa works as expected likely wouldn't be much extra work. The pattern-matching for the exa suffix and the exponent shouldn't be overlapping either way, I would imagine. A good TOML parser would currently also fail to parse something like It might make sense to make using key1 = 5e12 # Good
key2 = 5E12 # Bad since it is harder to read and also might be confused the exa- suffix
key3 = 5E # 5 exa = 5*10^18 While exa and above might not see much use immediately, it feels as though they should be there. Doing this over two iterations would just add more pain. |
Beyond the ambiguity pointed out above, I'm not sure it is immediately obvious to me what I don't think I can write down the values for these unless I scroll up to the table in OP, which makes me think that is needs way more context than I'd want a reader to have in mind when working on a TOML document. Yes, it'd be nice to have a good way to write 1048576 (that's 1024*1024) but that isn't something that can't be clarified today with a comment. Overall, I'm not convinced that the additional context and nuance needed to understand the proposed syntax adds enough actual value to the authoring/reading experience to justify adding it. |
Only speaking personally, I'm familiar with Could we have more comments from the scientific community about the utility of these suffixes, as opposed to using exponents with floats and using trains of And more comments from the tech community, who'd ostensibly benefit from |
I would agree with @eksortso that most people would be familiar with The ones above I personally don't like trains like I think this suggestion would mainly be targeted at tech, where the IEC suffices are clearly more readable than the alternative. |
Thanks, @JeppeKlitgaard. That
TOML is and ought to be language-agnostic. |
I'm gonna lean further into this and say that I don't think this is going to be beneficial overall. That isn't to say that this would not be useful in some cases, I'm sure it would be. I also think that this can be confusing on certain other contexts and that outweights the usefulness here IMO. Thanks for the discussion here folks, and for the patience! ^.^ |
I'm breaking this out from ticket #292 as I think it's a very useful feature that would be highly valued in scientific applications.
Proposal
For floating point and integer numbers allow SI and binary suffix modifiers. This suffix acts as a multiplier on the base value. The following table lists the supported suffixes.
Examples
Motivation
This would be very useful in scientific applications where this notation is common. However, it is also useful outside of the scientific community, for example when specifying the maximum disk space to allow.
The text was updated successfully, but these errors were encountered: