aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRobin Haberkorn <rhaberkorn@fmsbw.de>2026-11-18 12:24:37 +0100
committerRobin Haberkorn <rhaberkorn@fmsbw.de>2026-11-18 12:24:37 +0100
commitdaa46b24452c2c2eb817170d48a6585bec3c919e (patch)
treea9afe822dcd64f2df4e760b9ffc757414c47527a /src
parent45ef41a78b8dd0564b9d704ce2c4ad3c1b983ae5 (diff)
floating point NaNs are always printed as "nan"HEADmaster
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.
Diffstat (limited to 'src')
-rw-r--r--src/expressions.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/expressions.c b/src/expressions.c
index 68049eb..de256df 100644
--- a/src/expressions.c
+++ b/src/expressions.c
@@ -561,6 +561,14 @@ 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.
*/