-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorcontributor friendlyThis issue is limited in scope and/or knowledge of Zig internals.This issue is limited in scope and/or knowledge of Zig internals.standard libraryThis issue involves writing Zig code for the standard library.This issue involves writing Zig code for the standard library.
Milestone
Description
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:
const std = @import("std");
pub fn main() void {
const value = 30.0;
const value_to_str = std.fmt.comptimePrint("{d}", .{value});
std.debug.print("value = {s}\n", .{value_to_str});
}Expected output:
value = 30.0
Retrieved output:
An error occurred:
/usr/local/bin/lib/std/fmt.zig:1367:47: error: overflow of integer type 'u1' with value '2'
/usr/local/bin/lib/std/fmt.zig:802:27: note: called from here
/usr/local/bin/lib/std/fmt.zig:732:58: note: called from here
/usr/local/bin/lib/std/fmt.zig:487:31: note: called from here
/usr/local/bin/lib/std/fmt.zig:184:23: note: called from here
/usr/local/bin/lib/std/fmt.zig:2008:11: note: called from here
/usr/local/bin/lib/std/fmt.zig:2052:83: note: called from here
Code that works:
const std = @import("std");
pub fn main() void {
const value = 30.1;
const value_to_str = std.fmt.comptimePrint("{d}", .{value});
std.debug.print("value = {s}\n", .{value_to_str});
}Output:
value = 30.1
Metadata
Metadata
Assignees
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorcontributor friendlyThis issue is limited in scope and/or knowledge of Zig internals.This issue is limited in scope and/or knowledge of Zig internals.standard libraryThis issue involves writing Zig code for the standard library.This issue involves writing Zig code for the standard library.