musl - musl - an implementation of the standard library for Linux-based systems

index : musl
musl - an implementation of the standard library for Linux-based systems
summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2012年04月16日 01:53:52 -0400
committerRich Felker <dalias@aerifal.cx>2012年04月16日 01:53:52 -0400
commit2ac580fdfe1daf9924f221dc98878ae480306bfa (patch)
tree78e6e97b1801310be2bb4ae7085f3808b6bff1c8 /src
parent67b25fe0a8947de93e3eddd36dae24a9fec12ade (diff)
downloadmusl-2ac580fdfe1daf9924f221dc98878ae480306bfa.tar.gz
floatscan: fix incorrect count of leading nonzero digits
this off-by-one error was causing values with just one digit past the decimal point to be treated by the integer case. in many cases it would yield the correct result, but if expressions are evaluated in excess precision, double rounding may occur.
Diffstat (limited to 'src')
-rw-r--r--src/internal/floatscan.c 2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/internal/floatscan.c b/src/internal/floatscan.c
index 10123bfa..377a008b 100644
--- a/src/internal/floatscan.c
+++ b/src/internal/floatscan.c
@@ -81,8 +81,8 @@ static long double decfloat(FILE *f, int c, int bits, int emin, int sign, int po
if (lrp!=-1) break;
lrp = dc;
} else if (k < KMAX-2) {
- if (c!='0') lnz = dc;
dc++;
+ if (c!='0') lnz = dc;
if (j) x[k] = x[k]*10 + c-'0';
else x[k] = c-'0';
if (++j==9) {
generated by cgit v1.2.1 (git 2.18.0) at 2025年09月20日 07:30:40 +0000

AltStyle によって変換されたページ (->オリジナル) /