fix strtod and strtof rounding with many trailing zeros
commitd184a09e0529f33d8ddddb8825039133483a2c41
authorSzabolcs Nagy <nsz@port70.net>
Sun, 4 Sep 2016 02:46:00 +0000 (4 04:46 +0200)
committerRich Felker <dalias@aerifal.cx>
Thu, 20 Oct 2016 17:29:09 +0000 (20 13:29 -0400)
treeefccccc90b44504aa5ed2b04cd0cf15e1b291a80
parentf33b17585058381491e6fda08f491b8e48c7980c
fix strtod and strtof rounding with many trailing zeros

in certain cases excessive trailing zeros could cause incorrect
rounding from long double to double or float in decfloat.

e.g. in strtof("9444733528689243848704.000000", 0) the argument
is 0x1.000001p+73, exactly halfway between two representible floats,
this incorrectly got rounded to 0x1.000002p+73 instead of 0x1p+73,
but with less trailing 0 the rounding was fine.

the fix makes sure that the z index always points one past the last
non-zero digit in the base 10^9 representation, this way trailing
zeros don't affect the rounding logic.
src/internal/floatscan.c