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

Possible bug: f128 constant only has 16 decimals of precision when printed #3612

Closed
bdezonia opened this issue Nov 6, 2019 · 2 comments · Fixed by #19229
Closed

Possible bug: f128 constant only has 16 decimals of precision when printed #3612

bdezonia opened this issue Nov 6, 2019 · 2 comments · Fixed by #19229
Labels
bug Observed behavior contradicts documented or intended behavior contributor friendly This issue is limited in scope and/or knowledge of Zig internals. standard library This issue involves writing Zig code for the standard library.
Milestone

Comments

@bdezonia
Copy link

bdezonia commented Nov 6, 2019

Using 0.5.0 the following code:

var z : f128 = 1.738954882048422195749048390299;
warn("{:.34}\n",z);

Shows this:

1.7389548820484222000000000000000000e+00

It's like the compile time constant is 64 bit rather than 128 bit. The documentation implies that floating constants are 128 bit.

Is this a bug? Or am I doing something wrong?

@andrewrk andrewrk added this to the 0.7.0 milestone Nov 14, 2019
@andrewrk andrewrk added bug Observed behavior contradicts documented or intended behavior contributor friendly This issue is limited in scope and/or knowledge of Zig internals. standard library This issue involves writing Zig code for the standard library. labels Nov 14, 2019
@LakeByTheWoods
Copy link
Contributor

This is because the current float formatter internally works on 64bit floats. #1299 should fix this.

@Mouvedia
Copy link

dupe of #1181?

@andrewrk andrewrk modified the milestones: 0.7.0, 0.8.0 Oct 30, 2020
@andrewrk andrewrk modified the milestones: 0.8.0, 0.9.0 Nov 6, 2020
@andrewrk andrewrk modified the milestones: 0.9.0, 0.10.0 May 19, 2021
@andrewrk andrewrk modified the milestones: 0.15.0, 0.12.0 Mar 12, 2024
RossComputerGuy pushed a commit to ExpidusOS/zig that referenced this issue Mar 20, 2024
This replaces the errol backend with one based on ryu. The 128-bit
backend only is implemented. This supports all floating-point types and
does not use fp logic to print.

Closes ziglang#1181.
Closes ziglang#1299.
Closes ziglang#3612.
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 contributor friendly This issue is limited in scope and/or knowledge of Zig internals. standard library This issue involves writing Zig code for the standard library.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants