diff options
| author | kleink <kleink@NetBSD.org> | 2001-11-28 11:58:22 +0000 |
|---|---|---|
| committer | kleink <kleink@NetBSD.org> | 2001-11-28 11:58:22 +0000 |
| commit | 80f30d4de0087b1cc769bd532fc1d6d5b47a669f (patch) | |
| tree | ed0912ef9a2638103f9b4626ec5830fd7f5f8ecd /lib/libc/stdio/vfprintf.c | |
| parent | a268e72f56be232911f13e7947ff6e0f788e77ef (diff) | |
Since we're returned the sign of a floating-point number by __dtoa(),
use that to decide whether to include a minus sign in the result.
Fixes printing -0.0, and thus PR lib/3137.
Diffstat (limited to 'lib/libc/stdio/vfprintf.c')
| -rw-r--r-- | lib/libc/stdio/vfprintf.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/libc/stdio/vfprintf.c b/lib/libc/stdio/vfprintf.c index 479083c4d77..f042f383829 100644 --- a/lib/libc/stdio/vfprintf.c +++ b/lib/libc/stdio/vfprintf.c @@ -1,4 +1,4 @@ -/* $NetBSD: vfprintf.c,v 1.39 2001/11/27 18:05:30 augustss Exp $ */ +/* $NetBSD: vfprintf.c,v 1.40 2001/11/28 11:58:22 kleink Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -41,7 +41,7 @@ #if 0 static char *sccsid = "@(#)vfprintf.c 5.50 (Berkeley) 12/16/92"; #else -__RCSID("$NetBSD: vfprintf.c,v 1.39 2001/11/27 18:05:30 augustss Exp $"); +__RCSID("$NetBSD: vfprintf.c,v 1.40 2001/11/28 11:58:22 kleink Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -812,12 +812,12 @@ cvt(value, ndigits, flags, sign, decpt, ch, length) mode = 2; /* ndigits significant digits */ } - if (value < 0) { + digits = __dtoa(value, mode, ndigits, decpt, &dsgn, &rve); + if (dsgn) { value = -value; *sign = '-'; } else *sign = '\000'; - digits = __dtoa(value, mode, ndigits, decpt, &dsgn, &rve); if ((ch != 'g' && ch != 'G') || flags & ALT) { /* Print trailing zeros */ bp = digits + ndigits; if (ch == 'f') { |
