-
-
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
itrunc boundary issues #7517
Comments
Hmm. One problem with fixing this is that currently you can use |
@timholy What makes it faster? Is it just the avoidance of a comparison branch? Actually it turns out that this isn't machine arithmetic, as the same thing happens for any value outside the range, e.g. julia> itrunc(nextfloat(y))
-9223372036854775808 According to the C11 spec, "If the value of the integral part cannot be represented by the integer type, the behavior is undefined" |
Yes our |
Should we have this be safe by default and have an unsafe version for people who need it? |
I think in 0.3, for better or worse, this will be the unsafe version. We can change this when we start checking integer conversions. |
Seems like a good plan. Do we have an issue for that where we can add this as a todo item? |
@simonbyrne, yes, branches are very expensive. |
Ah the joys of edge cases...
convert(Int64,y)
and the other rounding functions (iceil
,ifloor
,iround
) all throwInexactError()
.The text was updated successfully, but these errors were encountered: