-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
std.fmt on comptime_int fails to handle some decimal values #18046
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
Comments
I think the offending line could be 1366 in lib.std.fmt.zig var i = num_digits_whole_no_pad; I'm not an expert of Zig by no means, but it seems to me that Changing the line to var i: u8 = num_digits_whole_no_pad; compiles. If I'm right, could somebody spend some time to mentor me (I'm absolutely a newbie) how to prove my solution has no side effects / regression and how to submit a pull request? Thank you, Luca- |
That's correct but it needs to be a
Add a new test to
That depends on your setup, GitHub probably has tutorials for all the common ones. |
I believe this has regressed (or maybe it was never fully fixed). Using the latest const std = @import("std");
pub fn main() void {
const value = 0.05;
const value_to_str = std.fmt.comptimePrint("{d}", .{value});
std.debug.print("value = {s}\n", .{value_to_str});
} |
Probably regressed with #19229 |
Closes ziglang#19379 Closes ziglang#18046
Closes ziglang#19379 Closes ziglang#18046
Closes ziglang#19379 Closes ziglang#18046
comptimePrint
doesn't handle correctly some decimal values (such as 300.0, but other are fine, such as 300.5).How to replicate the issue:
Expected output:
Retrieved output:
Code that works:
Output:
The text was updated successfully, but these errors were encountered: