-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Possible float parsing bug #20275
Labels
bug
Observed behavior contradicts documented or intended behavior
standard library
This issue involves writing Zig code for the standard library.
Milestone
Comments
MasonRemaley
added
the
bug
Observed behavior contradicts documented or intended behavior
label
Jun 12, 2024
tiehuis
added a commit
to tiehuis/zig
that referenced
this issue
Jun 14, 2024
There were two primary issues at play here: 1. The hex float prefix was not handled correctly when the stream was reset for the fallback parsing path, which occured when the mantissa was longer max mantissa digits. 2. The implied exponent was not adjusted for hex-floats in this branch. Additionally, some of the float parsing routines have been condensed, making use of comptime. closes ziglang#20275
ifreund
pushed a commit
that referenced
this issue
Jun 15, 2024
There were two primary issues at play here: 1. The hex float prefix was not handled correctly when the stream was reset for the fallback parsing path, which occured when the mantissa was longer max mantissa digits. 2. The implied exponent was not adjusted for hex-floats in this branch. Additionally, some of the float parsing routines have been condensed, making use of comptime. closes #20275
Vexu
added
the
standard library
This issue involves writing Zig code for the standard library.
label
Jun 15, 2024
ryoppippi
pushed a commit
to ryoppippi/zig
that referenced
this issue
Jul 5, 2024
There were two primary issues at play here: 1. The hex float prefix was not handled correctly when the stream was reset for the fallback parsing path, which occured when the mantissa was longer max mantissa digits. 2. The implied exponent was not adjusted for hex-floats in this branch. Additionally, some of the float parsing routines have been condensed, making use of comptime. closes ziglang#20275
SammyJames
pushed a commit
to SammyJames/zig
that referenced
this issue
Aug 7, 2024
There were two primary issues at play here: 1. The hex float prefix was not handled correctly when the stream was reset for the fallback parsing path, which occured when the mantissa was longer max mantissa digits. 2. The implied exponent was not adjusted for hex-floats in this branch. Additionally, some of the float parsing routines have been condensed, making use of comptime. closes ziglang#20275
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug
Observed behavior contradicts documented or intended behavior
standard library
This issue involves writing Zig code for the standard library.
Zig Version
0.14.0-dev.23+d9bd34fd0
Steps to Reproduce and Observed Behavior
The following test fails:
At first glance it's hard to imagine why this would fail, since the compiler itself is using
parseFloat
as well. However, the compiler always parses floats as f128s, so here's a more illustrative test case:If I understand the situation correctly, this should pass:
Besides resulting in an incorrect value, this has a minor detrimental effect on #20271--in the interest of being consistent results with Zig, the ZON parser has to parse all floats as f128s even when it knows the destination precision and could technically save time by parsing as f32s.
I suspect that the cause of this is related to either rounding modes or handling of very large/out of range floats, but I'm not sure how to dig in further.
Expected Behavior
I expected parsing floating point literal strings as a given type to produce the same result as including that literal in the source code and ascribing the same type.
The text was updated successfully, but these errors were encountered: