From 3a0d818c0ece10f5b84eddededfeeeca727c7638 Mon Sep 17 00:00:00 2001 From: Marius Gerbershagen Date: Sat, 21 Jan 2023 17:37:51 +0100 Subject: [PATCH] printer: print zero after decimal point in exponential notation if there are no other trailing digits Previously for example (prin1 1.0e-8) would result in 1.e-8. However, the ANSI standard (see CLHS section 22.1.3.1.3) specifies that there has to be at least one digit after the decimal point therefore we now print 1.0e-8. --- src/c/printer/float_to_string.d | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/c/printer/float_to_string.d b/src/c/printer/float_to_string.d index 403c11c33..193a7dae3 100644 --- a/src/c/printer/float_to_string.d +++ b/src/c/printer/float_to_string.d @@ -107,7 +107,12 @@ si_float_to_string_free(cl_object buffer_or_nil, cl_object number, } /* Do we have to print in exponent notation? */ if (ecl_lowereq(exp, e_min) || ecl_lowereq(e_max, exp)) { - insert_char(buffer, base+1, '.'); + if (ecl_length(buffer) == base+1) { + insert_char(buffer, base+1, '.'); + insert_char(buffer, base+2, '0'); + } else { + insert_char(buffer, base+1, '.'); + } print_float_exponent(buffer, number, e-1); } else if (e > 0) { cl_fixnum l = buffer->base_string.fillp - base;