Date: Wed, 21 Aug 2002 04:22:19 -0700 (PDT)
From: Jens Schweikhardt <schweikh@FreeBSD.org>
To: gotoken@notwork.org, schweikh@FreeBSD.org, freebsd-bugs@FreeBSD.org
Subject: Re: bin/41823: printf("%+f\n", -0.0) generates +0.000000
Message-ID: <200208211122.g7LBMJrt092651@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
Synopsis: printf("%+f\n", -0.0) generates +0.000000
State-Changed-From-To: open->analyzed
State-Changed-By: schweikh
State-Changed-When: Wed Aug 21 04:10:56 PDT 2002
State-Changed-Why:
You are correct, ISO9899:1999 states in footnote 233)
"The results of all floating conversions of a negative zero,
and of negative values that round to zero, include a minus sign."
Can you try this patch against -current? (stable should be easy too).
This is what you suggested, I believe, i.e. moving the __dtoa()
before the comparison and using "if (dsgn)" instead of value<0.
This would align us a little closer to NetBSD as you stated.
Index: src/lib/libc/stdio/vfprintf.c
===================================================================
RCS file: /home/ncvs/src/lib/libc/stdio/vfprintf.c,v
retrieving revision 1.43
diff -u -r1.43 vfprintf.c
--- src/lib/libc/stdio/vfprintf.c 15 Aug 2002 10:28:52 -0000 1.43
+++ src/lib/libc/stdio/vfprintf.c 21 Aug 2002 11:17:14 -0000
@@ -1409,13 +1409,13 @@
ndigits++;
mode = 2; /* ndigits significant digits */
}
- if (value < 0) {
+ digits = __dtoa(value, mode, ndigits, decpt, &dsgn, &rve,
+ dtoaresultp);
+ if (dsgn) {
value = -value;
*sign = '-';
} else
*sign = '\000';
- digits = __dtoa(value, mode, ndigits, decpt, &dsgn, &rve,
- dtoaresultp);
if ((ch != 'g' && ch != 'G') || flags & ALT) {
/* print trailing zeros */
bp = digits + ndigits;
http://www.freebsd.org/cgi/query-pr.cgi?pr=41823
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?200208211122.g7LBMJrt092651>
