Measurements.jl
Measurements.jl copied to clipboard
Incorrect `round`ing when using `sigdigits` keyword argument
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).
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