From 8b074d2e397b2e8a5de2f17fa17c97ad2256bd85 Mon Sep 17 00:00:00 2001 From: Will Anderson Date: Wed, 6 May 2026 17:49:35 -0500 Subject: [PATCH] fix: normalize NaN to 'nan' in float_to_str regardless of sign bit 0.0/0.0 can produce -nan on Linux/x86_64 (%g gives '-nan'), causing the no-cycle calendar test to fail. Explicitly check isnan() and emit 'nan' so behavior is platform-independent. --- lang/el-compiler/runtime/el_runtime.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lang/el-compiler/runtime/el_runtime.c b/lang/el-compiler/runtime/el_runtime.c index df25f4a..9320c1a 100644 --- a/lang/el-compiler/runtime/el_runtime.c +++ b/lang/el-compiler/runtime/el_runtime.c @@ -4999,7 +4999,13 @@ el_val_t state_get_or(el_val_t key, el_val_t default_val) { el_val_t float_to_str(el_val_t f) { char buf[64]; - snprintf(buf, sizeof(buf), "%g", el_to_float(f)); + double v = el_to_float(f); + /* Normalize NaN to "nan" regardless of sign — platform-independent. */ + if (isnan(v)) { + snprintf(buf, sizeof(buf), "nan"); + } else { + snprintf(buf, sizeof(buf), "%g", v); + } return el_wrap_str(el_strdup(buf)); }