055-fix-strtod-int-optimization-in-non-nearest-rounding-mode.patch 1.2 KB

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