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

No InexactError for Int32 #7441

Closed
bkamins opened this issue Jun 28, 2014 · 1 comment
Closed

No InexactError for Int32 #7441

bkamins opened this issue Jun 28, 2014 · 1 comment
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@bkamins
Copy link
Member

bkamins commented Jun 28, 2014

I am running Julia Version 0.3.0-prerelease+3679. Commit d0eac34
on Windows with WORD_SIZE 32.

The following behavior is inconsistent:
int64(2.0^300) # throws InexactError()
int32(2.0^300) # throws InexactError()
but
int64(2.0^50) # 1125899906842624
int32(2.0^50) # 0
So for int32 InexactError is not thrown when value is too big for 32-bits but less than 64-bits. I would expect Julia to consistently throw InexactError in such cases.

The reason for this behavior is line 81 in file float.jl:
iround(x::Float64) = int32(box(Int64,fpsiround(unbox(Float64,x))))

@bkamins
Copy link
Member Author

bkamins commented Jun 28, 2014

Additionally note that convert(Int32, 2.0^50) throws InexactError() as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants