Date: Sun, 25 Aug 2002 18:20:03 -0700 (PDT) From: Bruce Evans <bde@zeta.org.au> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/41823: printf("%+f\n", -0.0) generates +0.000000 Message-ID: <200208260120.g7Q1K3vf017098@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/41823; it has been noted by GNATS. From: Bruce Evans <bde@zeta.org.au> To: Jens Schweikhardt <schweikh@schweikhardt.net> Cc: GNATS Bug Followup <bug-followup@FreeBSD.org> Subject: Re: bin/41823: printf("%+f\n", -0.0) generates +0.000000 Date: Mon, 26 Aug 2002 11:25:06 +1000 (EST) On Sun, 25 Aug 2002, Jens Schweikhardt wrote: > Ok, here's a patch you'll like -- it reduces the lines of code :-) > > Index: vfprintf.c > =================================================================== > RCS file: /home/ncvs/src/lib/libc/stdio/vfprintf.c,v > retrieving revision 1.43 > diff -u -r1.43 vfprintf.c > --- vfprintf.c 15 Aug 2002 10:28:52 -0000 1.43 > +++ vfprintf.c 25 Aug 2002 13:26:08 -0000 > @@ -1409,13 +1409,8 @@ > ndigits++; > mode = 2; /* ndigits significant digits */ > } > - if (value < 0) { > - value = -value; > - *sign = '-'; > - } else > - *sign = '\000'; > - digits = __dtoa(value, mode, ndigits, decpt, &dsgn, &rve, > - dtoaresultp); > + digits = __dtoa(value, mode, ndigits, decpt, &dsgn, &rve, dtoaresultp); > + *sign = dsgn != 0; > if ((ch != 'g' && ch != 'G') || flags & ALT) { > /* print trailing zeros */ > bp = digits + ndigits; > Yes, I like it. Assuming that it works of course. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200208260120.g7Q1K3vf017098>