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

Incorrect rounding when using sigdigits keyword argument #34

Open
pyramids opened this issue Mar 21, 2019 · 1 comment
Open

Incorrect rounding when using sigdigits keyword argument #34

pyramids opened this issue Mar 21, 2019 · 1 comment

Comments

@pyramids
Copy link

julia> round(((12.34±0.02)u"m")/1.0u"m", sigdigits=2)u"m"
12.0 ± 0.02 m

This is counterintuitive and, frankly, incorrect. I expect a result where the uncertainty has been extended to represent the rounding, e.g. 12.0 ± 0.5 m (for the nearest rounding mode). Arguably also correct would be 12.0 ± 1.0 m (round both the value and the uncertainty to the same digit, not to the same sigdigits).

@giordano
Copy link
Member

I agree that this could be counterintuitive, but I think the real problem is that method is ambiguous: what does "sigdigits" refers to? Everybody can claim that The Right Answer™ is either "to the value" or "to the uncertainty". You also suggest this.

Note that this is unrelated to Unitful.jl:

julia> round(12.34±0.02, sigdigits=2)
12.0 ± 0.02

@giordano giordano changed the title Incorrect Rounding with Unitful Incorrect rounding when using sigdigits keyword argument Aug 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants