Skip to content

Fix over/underflow in parsing float literals#78

Merged
c42f merged 3 commits intomainfrom
cjf/parse-float-erange
Aug 30, 2022
Merged

Fix over/underflow in parsing float literals#78
c42f merged 3 commits intomainfrom
cjf/parse-float-erange

Conversation

@c42f
Copy link
Copy Markdown
Member

@c42f c42f commented Aug 26, 2022

It seems we can't use Base.parse for floats because this disallows
underflow. So replicate the logic of it here in julia-level code and allow
errno=ERANGE in the underflow case.

This implementation is still somewhat (~15%) slower than Base.parse for some reason.

Should fix #65

TODO:

  • Tests

c42f added 3 commits August 26, 2022 20:35
It seems we can't use Base.parse for floats because this disallows
underflow. So replicate the logic of it here in julia-level code.

This implementation is still somewhat (~15%) slower than Base.parse for
some reason.
We probably shoudln't be modifying the memory in a String on the slow
path here, so use a Vector{UInt8} as the buffer instead. Also deal with
some weird codegen issue which came up as a result on julia 1.6 / 1.7.
Add tests.
@c42f c42f force-pushed the cjf/parse-float-erange branch from 6a54398 to a1b9780 Compare August 30, 2022 07:47
@c42f
Copy link
Copy Markdown
Member Author

c42f commented Aug 30, 2022

Uuugh come on. It seems libc strtof is buggy on windows JuliaLang/julia#46544

@c42f c42f merged commit 7951c0e into main Aug 30, 2022
@c42f c42f deleted the cjf/parse-float-erange branch August 30, 2022 08:07
c42f added a commit to JuliaLang/julia that referenced this pull request Oct 17, 2025
…se-float-erange

Fix over/underflow in parsing float literals
topolarity pushed a commit to JuliaLang/julia that referenced this pull request Nov 14, 2025
…se-float-erange

Fix over/underflow in parsing float literals
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 this pull request may close these issues.

Failures parsing underflow and overflow of Float64 literals

1 participant