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

disable InexactError for runtime parsing #127

Closed
stevengj opened this issue May 14, 2020 · 3 comments
Closed

disable InexactError for runtime parsing #127

stevengj opened this issue May 14, 2020 · 3 comments
Labels

Comments

@stevengj
Copy link
Member

stevengj commented May 14, 2020

Currently,

julia> parse(Dec32, "1.999999999999999999")
ERROR: InexactError: parse(Dec32, 1.999999999999999999)

julia> parse(Float32, "1.999999999999999999")
2.0f0

which is rather inconsistent. My feeling is that we should disable InexactError for runtime calls to parse and just return the closest rounded value.

On the other hand, we should probably keep the error for compile-time constants via the dXX"..." string macros

julia> d32"1.999999999999999999"
ERROR: LoadError: InexactError: parse(Dec32, 1.999999999999999999)

since in these cases it seems likely that an exact decimal constant was intended and an error is more useful than a rounded result.

@jmkuhn
Copy link
Contributor

jmkuhn commented May 14, 2020

Yes, I have been looking at this as well.

@jmkuhn
Copy link
Contributor

jmkuhn commented Jun 11, 2020

Currently on master I have

julia> parse(Dec32, "1.999999999999999999")
2.0

julia> parse(Float32, "1.999999999999999999")
2.0f0

julia> d32"1.999999999999999999"
2.0

which is what we want for parse but not for the string macros. Changing this would be breaking so this should be resolved before 1.0.

@stevengj
Copy link
Member Author

Resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants