summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio
diff options
context:
space:
mode:
authorschweikh <schweikh@FreeBSD.org>2002-08-27 20:11:08 +0000
committerschweikh <schweikh@FreeBSD.org>2002-08-27 20:11:08 +0000
commit57bf7bbe3fac912b8371b0435ecafcca3a923327 (patch)
tree65fdc6ccfc7daabbf34b98094d23dfc7077bf6d4 /lib/libc/stdio
parenteef2c40d6eae1755247ab792bad1cd31d4b7ffca (diff)
downloadFreeBSD-src-57bf7bbe3fac912b8371b0435ecafcca3a923327.zip
FreeBSD-src-57bf7bbe3fac912b8371b0435ecafcca3a923327.tar.gz
Print a '-' sign for negative zero. Tested with
#include <stdio.h> int main(void) { printf("%+f\n", -0.0); printf("%+f\n", +0.0); printf("%+f\n", 0.0); return 0; } to output -0.000000 +0.000000 +0.000000 PR: bin/41823 Submitted by: GOTO Kentaro <gotoken@notwork.org> Liked by: bde MFC after: 3 weeks
Diffstat (limited to 'lib/libc/stdio')
-rw-r--r--lib/libc/stdio/vfprintf.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/lib/libc/stdio/vfprintf.c b/lib/libc/stdio/vfprintf.c
index 91bbe00..1802fc7 100644
--- a/lib/libc/stdio/vfprintf.c
+++ b/lib/libc/stdio/vfprintf.c
@@ -1409,13 +1409,8 @@ cvt(double value, int ndigits, int flags, char *sign, int *decpt,
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;
OpenPOWER on IntegriCloud