aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2021-04-08 12:28:21 +0200
committerThomas White <taw@physics.org>2021-04-08 12:28:21 +0200
commit8e2ede804a961fb4c516c9060d5ab20df2b5848c (patch)
tree43d9b840faf00ae6591e9d51557894b2eb0135ee
parent03f1a81fc2acbd0c6fead61925faf2179f1b8367 (diff)
Record infinite values as 'null' in JSON
Infinity isn't allowed in JSON. 'Null' should serve equally well to indicate "the relevant feature has been switched off".
-rw-r--r--src/json-utils.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/json-utils.h b/src/json-utils.h
index 5c03256b..211a861c 100644
--- a/src/json-utils.h
+++ b/src/json-utils.h
@@ -30,7 +30,7 @@ static void write_float(FILE *fh, int comma, const char *name, float val)
{
const char *cs = comma ? "," : "";
- if ( isnan(val) ) {
+ if ( isnan(val) || isinf(val) ) {
fprintf(fh, " \"%s\": null%s\n", name, cs);
} else if ( val > 0.0001 ) {
fprintf(fh, " \"%s\": %f%s\n", name, val, cs);