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

Rounding with digits/sigdigits #307

Closed
sostock opened this issue Feb 14, 2020 · 0 comments · Fixed by #308
Closed

Rounding with digits/sigdigits #307

sostock opened this issue Feb 14, 2020 · 0 comments · Fixed by #308

Comments

@sostock
Copy link
Collaborator

sostock commented Feb 14, 2020

round with the digits/sigdigits keyword only really works with quantities based on floating-point numbers:

julia> round(u"m", (120//1)u"cm", sigdigits=2)
5404319552844595//4503599627370496 m

julia> round(u"m", 120u"cm", sigdigits=2)
ERROR: InexactError: Int64(1.2)

For unitless numbers, round always returns a float when sigdigits/digits is used. Maybe Unitful should do the same.

julia> round(120//100, sigdigits=2)
1.2

julia> round(125, sigdigits=2)
120.0
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

Successfully merging a pull request may close this issue.

1 participant