Fix printing of single-precision floats.
If there's already an exponent separator, replace it with f. Closes PR12836.
This commit is contained in:
parent
5caa114564
commit
a89bd99e2a
|
@ -17,6 +17,10 @@
|
|||
(10.0f0 "1S1")
|
||||
(10.0f0 "1f1")
|
||||
(10.0f0 "1F1")
|
||||
(1.0f32 "1f32")
|
||||
(1.0f32 "1F32")
|
||||
(1.0f32 "1f+32")
|
||||
(1.0f-32 "1f-32")
|
||||
(10.0 "1l1")
|
||||
(10.0 "1L1")
|
||||
(10.0 "1d1")
|
||||
|
|
|
@ -1620,13 +1620,21 @@ static char *double_to_string (double d, int alloc, int was_single)
|
|||
}
|
||||
#ifdef MZ_USE_SINGLE_FLOATS
|
||||
if (was_single) {
|
||||
/* In case of a single-precision float, add the f0 suffix to
|
||||
cause the string to be read back as a single-precision
|
||||
float. */
|
||||
buffer[l] = 'f';
|
||||
buffer[l + 1] = '0';
|
||||
buffer[l + 2] = 0;
|
||||
l += 2;
|
||||
/* In case of a single-precision float, add the f0 suffix (or
|
||||
replace the existing e exponent separator) to cause the
|
||||
string to be read back as a single-precision float. */
|
||||
for (i = 0; i < l; i++) {
|
||||
if (buffer[i] == 'e')
|
||||
break;
|
||||
}
|
||||
if (i == l) {
|
||||
buffer[l] = 'f';
|
||||
buffer[l + 1] = '0';
|
||||
buffer[l + 2] = 0;
|
||||
l += 2;
|
||||
} else {
|
||||
buffer[i] = 'f';
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user