diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2022-11-02 15:00:38 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2022-11-02 15:00:38 (GMT) |
commit | 809aebe98e82963644d807264b624759ef99372e (patch) | |
tree | 03f22eccd172462f6c2b2affe2da092af3f89cec /generic/tclBinary.c | |
parent | 6ab05e04d1c2e4d0a473c114f67d7a8f1cab4dbd (diff) | |
parent | 9244b6ed0810e743ee573d8403df7283d9e1486e (diff) | |
download | tcl-809aebe98e82963644d807264b624759ef99372e.zip tcl-809aebe98e82963644d807264b624759ef99372e.tar.gz tcl-809aebe98e82963644d807264b624759ef99372e.tar.bz2 |
Proposed fix for [85ce4bf928]: Fix for problems with storing Inf with [binary format R]
Diffstat (limited to 'generic/tclBinary.c')
-rw-r--r-- | generic/tclBinary.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/generic/tclBinary.c b/generic/tclBinary.c index 8b974c1..3fa5a6b 100644 --- a/generic/tclBinary.c +++ b/generic/tclBinary.c @@ -2193,7 +2193,9 @@ FormatNumber( * valid range for float. */ - if (fabs(dvalue) > (double) FLT_MAX) { + if (fabs(dvalue) > (FLT_MAX + pow(2, (FLT_MAX_EXP - FLT_MANT_DIG - 1)))) { + fvalue = (dvalue >= 0.0) ? INFINITY : -INFINITY; // c99 + } else if (fabs(dvalue) > (double) FLT_MAX) { fvalue = (dvalue >= 0.0) ? FLT_MAX : -FLT_MAX; } else { fvalue = (float) dvalue; |