-
-
Notifications
You must be signed in to change notification settings - Fork 42
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
Surprising parse behavior of quotient units. #249
Comments
Which |
SimpleUnitFormat |
Did you try others like |
Simple class demonstrating behavior. Output is '[L]'l instead of expected '[L]/[T]^2' `import tech.units.indriya.format.SimpleUnitFormat; /**
}` |
EBNFFormat works, but it does not have the 'alias' capability of SimpleUnitFormat, which is critical for my application. `import tech.units.indriya.format.EBNFUnitFormat; /**
} |
Ok, based on your comments, I've figured out how to do aliases using EBNFFormat: `import java.io.PrintStream; import tech.units.indriya.format.EBNFUnitFormat; /**
} Thank you. It turns out that this leads to a new problem, EBNFUnitParser won't accept a unit alias called 'e'. I'll post a second report on this problem. |
see issue #250 for the problem with using the alias 'e' in the EBNFUnitParser. |
If you're happy to use the mentioned demo as a basis for demos in https://github.com/unitsofmeasurement/uom-demos/tree/master/console/basic/src/main/java/tech/uom/demo/format, feel free to propose a PR or we could also do that. Can this ticket otherwise be closed? I saw the other one, similar to using "1" as a unit it may be a bit trickier because "e" is a regular part of very large or small numbers. |
Go ahead and close the ticket. I'm not quite understanding the question about a PR - do you mean add the simple demo I posted above as an addition to the demo/format directory as a PR? If that's the question, I'd be happy to do it, otherwise let me know what you'd like. |
Yes, uom-demos, but we can do that if you don't. Unlike the main RI code here everyone is free to participate in the demos and other projects. Only the parts that make up the JSR (API, RI and TCK) are a little more restricted for contribution without contributor agreements because of JCP requirements. |
I would expect the unit string 'm/s/s' to have dimensions L/T^2, but instead it has dimension L. I understand that there is ambiguity in the order of evaluation of the '/' operators. If we evaluate the '/' right to left, then s/s = 1, and m/1 = m, with dimensions L, whereas if we evaluate the '/' left to right, then we have (m/s)/s = m/s^2, with dimensions L/T^2.
I admit that there is a formal problem with m/s/s, but I am (very) certain that every scientist and engineer who sees (or enters into software) the string 'm/s/s', would expect the resulting unit to have dimensions L/T^2. I request that the quotient operators be evaluated left to right, thus preserving the principle of least surprise.
The text was updated successfully, but these errors were encountered: