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)); }