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.
This commit is contained in:
Marius Gerbershagen 2023-01-21 17:37:51 +01:00
parent 3d809dab47
commit 3a0d818c0e

View file

@ -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;