summaryrefslogtreecommitdiffstats
path: root/generic/tclBinary.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2022-11-02 15:00:38 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2022-11-02 15:00:38 (GMT)
commit809aebe98e82963644d807264b624759ef99372e (patch)
tree03f22eccd172462f6c2b2affe2da092af3f89cec /generic/tclBinary.c
parent6ab05e04d1c2e4d0a473c114f67d7a8f1cab4dbd (diff)
parent9244b6ed0810e743ee573d8403df7283d9e1486e (diff)
downloadtcl-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.c4
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;