1 From 6ffdc4579ffb34f4aab69ab4c081badabc7c0a9a Mon Sep 17 00:00:00 2001
2 From: Szabolcs Nagy <nsz@port70.net>
3 Date: Sun, 4 Sep 2016 04:51:03 +0200
4 Subject: fix strtod int optimization in non-nearest rounding mode
6 the mid-sized integer optimization relies on lnz set up properly
7 to mark the last non-zero decimal digit, but this was not done
8 if the non-zero digit lied outside the KMAX digits of the base
9 10^9 number representation.
11 so if the fractional part was a very long list of zeros (>2048*9 on
12 x86) followed by non-zero digits then the integer optimization could
13 kick in discarding the tiny non-zero fraction which can mean wrong
14 result on non-nearest rounding mode.
16 strtof, strtod and strtold were all affected.
18 src/internal/floatscan.c | 5 ++++-
19 1 file changed, 4 insertions(+), 1 deletion(-)
21 diff --git a/src/internal/floatscan.c b/src/internal/floatscan.c
22 index 80305ee..ae09852 100644
23 --- a/src/internal/floatscan.c
24 +++ b/src/internal/floatscan.c
25 @@ -110,7 +110,10 @@ static long double decfloat(FILE *f, int c, int bits, int emin, int sign, int po
29 - if (c!='0') x[KMAX-4] |= 1;