-
Notifications
You must be signed in to change notification settings - Fork 97
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 behaviour when comparing non-metric units #496
Comments
Worth mentioning that disabling the |
I put a lot of time into [1] Lines 297 to 357 in d385d79
|
I have the following code, which defines a foot/pound/second system of units:
My expectation is that the test will pass, as
value
should be equal to itself.Instead, I get the following error:
This is surprising because:
value.value
, orvalue.get::<foot>()
, etc. the test passes.I looked into Quantity's
PartialEq
implementation, and saw that it callschange_base
on the right operand to handle the fact that the operand types can have differentU
parameters.change_base
looks like this:Essentially since I'm not using metric units, we end up having something that looks like this:
These operations don't cancel out due to floating point error, so we end up with a different value, hence the assertion failure.
I'm not sure what uom could do to handle this better, but it is unfortunate that these conversions have to happen at all when comparing values in the same unit system. There's probably a performance overhead to that as well?
uom version: 0.36.0
I have a minimal repro of the issue here: https://github.com/nsunderland1/uom-partialeq
The text was updated successfully, but these errors were encountered: