From daa46b24452c2c2eb817170d48a6585bec3c919e Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Wed, 18 Nov 2026 12:24:37 +0100 Subject: floating point NaNs are always printed as "nan" FreeBSD's libc gives fmod(1, 0) as nan, while Ubuntu/glibc produces -nan. This broke the test suite on Linux. Instead, we now print -nan as "nan" as well. The sign bit shouldn't convey any meaning, at least in SciTECO where you cannot do any NaN-boxing. --- src/expressions.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/expressions.c b/src/expressions.c index 68049eb..de256df 100644 --- a/src/expressions.c +++ b/src/expressions.c @@ -560,6 +560,14 @@ teco_expressions_format_int(gchar *buffer, teco_int_t number, teco_qreg_t *qreg) gchar * teco_expressions_format_float(gchar *buffer, teco_float_t number, guint precision) { + /* + * fmod(1, 0) gives -nan on glibc and nan on FreeBSD. + * For printing, we normalize the output since the nan sign does + * not convey any meaning. + */ + if (isnan(number)) + number = NAN; + /* * Do not print in scientific notation (with an exponent) - we cannot * write such constants in SciTECO, so we don't want to format them either. -- cgit v1.2.3