diff --git a/lib/std/collections/object.c3 b/lib/std/collections/object.c3 index 7253cd022..f14dc87d0 100644 --- a/lib/std/collections/object.c3 +++ b/lib/std/collections/object.c3 @@ -67,7 +67,7 @@ fn usz! Object.to_format(&self, Formatter* formatter) @dynamic case UNSIGNED_INT: return formatter.printf("%d", (uint128)self.i)!; case FLOAT: - return formatter.printf("%d", self.f)!; + return formatter.printf("%g", self.f)!; case ENUM: return formatter.printf("%d", self.i)!; default: diff --git a/lib/std/io/formatter_private.c3 b/lib/std/io/formatter_private.c3 index fbdcb34d3..760eb4ff1 100644 --- a/lib/std/io/formatter_private.c3 +++ b/lib/std/io/formatter_private.c3 @@ -214,7 +214,7 @@ fn usz! Formatter.floatformat(&self, FloatFormatting formatting, double y) @priv // Add padding if (!self.flags.left) len += self.pad(' ', self.width, 3 + pl)!; String s = self.flags.uppercase ? "INF" : "inf"; - if (y != y) s = self.flags.uppercase ? "NAN" : "nan"; + if (math::is_nan(y)) s = self.flags.uppercase ? "NAN" : "nan"; len += s.len; if (pl) len += self.out(is_neg ? '-' : '+')!; len += self.out_chars(s)!;