Prechádzať zdrojové kódy

fix float scanning of certain values ending in zeros

for example, "1000000000" was being read as "1" due to this loop
exiting early. it's necessary to actually update z and zero the
entries so that the subsequent rounding code does not get confused;
before i did that, spurious inexact exceptions were being raised.
Rich Felker 13 rokov pred
rodič
commit
38b3f1fea8
1 zmenil súbory, kde vykonal 3 pridanie a 1 odobranie
  1. 3 1
      src/internal/floatscan.c

+ 3 - 1
src/internal/floatscan.c

@@ -225,8 +225,10 @@ static long double decfloat(FILE *f, int bits, int emin, int sign, int pok)
 		}
 	}
 
-	for (y=i=0; i<LD_B1B_DIG && (a+i & MASK)!=z; i++)
+	for (y=i=0; i<LD_B1B_DIG; i++) {
+		if ((a+i & MASK)==z) x[z=(z+1 & MASK)] = 0;
 		y = 1000000000.0L * y + x[a+i & MASK];
+	}
 
 	y *= sign;