diff --git a/collects/tests/racket/numstrs.rktl b/collects/tests/racket/numstrs.rktl index e4490fe132..8349eb0bdf 100644 --- a/collects/tests/racket/numstrs.rktl +++ b/collects/tests/racket/numstrs.rktl @@ -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") diff --git a/src/racket/src/numstr.c b/src/racket/src/numstr.c index a7fa4d2e70..79e8150011 100644 --- a/src/racket/src/numstr.c +++ b/src/racket/src/numstr.c @@ -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