-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
round(x, ndigits) where x is like 1.0e+/-k does not work #26663
Comments
If you want to fold |
that's not a bad idea. We could use |
it is nice to have round(x, abs(n)) indicate digits to the right of the decimal point and round(x, -abs(n)) indicate digits to the left of the decimal point. round uses digits as an arg name at the moment, so a keyword would be |
My idea would be to make both |
is there a way to specify "only one of these may be given" in the signature or does that test have to occur inside the function? |
and .. having both as keywords makes sense to me |
The main issue is that it makes dispatch and extensions a bit complicated. e.g. if I define a new number type |
is there a way for us to supply a general purpose sensibly behaving fallback for just such occasions? maybe an alternative, so other types do not have to stress it # where {T} written in a white font
round(x::T; digits::Int) = round_with_digits(x, digits)
round(x::T; sigdigits::Int) = round_with_sigdigits(x, sigdigits)
round(x::T; digits::Int, sigdigits::Int) = throw(ErrorException("use either `digits` or `sigdigits`, use of both simultaneously is not supported")
round(x::T, digits::Int) = round_with_digits(x, digits) |
One feature that I'd like to have in |
It is always beneficial to support RoundingMode. Note that for this situation, some wrapping logic may be needed because |
One step ahead: https://github.com/JuliaLang/julia/pull/26670/files#diff-a6b2d98c6bbc2867449a6c3514854ff3R47 |
Was fixed by #26670 |
please see this thread for the details
The text was updated successfully, but these errors were encountered: