mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Fix Formatter.floatformat and Object.to_format (#1602)
* fix: change float format specifier in Object.to_format Fix the float format specifier in Object.to_format. If there is a float stored in a Object such as 3.14, it would be printed out as 3 because the format specifier is %d but should be %g. * fix: print nan in floatformat Fix floatformat to print 'nan' if float is nan. Currently, io::printn(float.nan) will produce 'inf' instead of 'nan'.
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user