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.
This commit is contained in:
parent
a268e72f56
commit
80f30d4de0
|
@ -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') {
|
||||
|
|
Loading…
Reference in New Issue