Skip to content

Commit f1dea4c

Browse files
authored
Fix precision bug for LONGREAL literal.
Emit enough significant digits for the C compiler to re-parse the exact binary value: a 64-bit LONGREAL needs 17 (DBL_DECIMAL_DIG). The old 13 truncated the literal, so C parsed a rounded, different double — a C-backend float-literal precision bug.
1 parent e4ba87a commit f1dea4c

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

m3-sys/m3middle/src/TFloat.m3

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ PROCEDURE ToChars (READONLY f: Float; VAR buf: ARRAY OF CHAR): INTEGER =
165165
IF f.pre = Precision.Short THEN
166166
len := Convert.FromFloat (zz, FLOAT(f.fraction, REAL), 13, Convert.Style.Sci);
167167
ELSIF f.pre = Precision.Long THEN
168-
len := Convert.FromLongFloat (zz, FLOAT(f.fraction, LONGREAL), 13, Convert.Style.Sci);
168+
len := Convert.FromLongFloat (zz, FLOAT(f.fraction, LONGREAL), 17, Convert.Style.Sci);
169169
ELSE
170170
len := Convert.FromExtended (zz, f.fraction, 36, Convert.Style.Sci);
171171
END;

0 commit comments

Comments
 (0)