fix: normalize NaN to 'nan' in float_to_str regardless of sign bit
El SDK CI - dev / build-and-test (pull_request) Successful in 3m18s
El SDK CI - dev / build-and-test (pull_request) Successful in 3m18s
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.
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user