avoid raising spurious division-by-zero exception in printf
authorRich Felker <dalias@aerifal.cx>
Fri, 19 Oct 2012 00:26:41 +0000 (20:26 -0400)
committerRich Felker <dalias@aerifal.cx>
Fri, 19 Oct 2012 00:26:41 +0000 (20:26 -0400)
src/stdio/vfprintf.c

index 6525938f20584ff5c334a23a1cafc0cd36ce62f3..4a2752b275834d76786bc6af95b238f92831e37b 100644 (file)
@@ -200,7 +200,7 @@ static int fmt_fp(FILE *f, long double y, int w, int p, int fl, int t)
        char ebuf0[3*sizeof(int)], *ebuf=&ebuf0[3*sizeof(int)], *estr;
 
        pl=1;
-       if (y<0 || 1/y<0) {
+       if (signbit(y)) {
                y=-y;
        } else if (fl & MARK_POS) {
                prefix+=3;