Gregor Schneider <grschneider@gmail.com>

- Only pad with zeroes if padding requested.
- Show signs for floating point numbers without checking for SIGN type (since there is no unsigned float/double).
See issue #3587 for more details.

svn path=/trunk/; revision=35764
This commit is contained in:
Aleksey Bragin 2008-08-29 18:57:31 +00:00
parent 7f5edc03e3
commit 78adf1b7db

View file

@ -167,7 +167,6 @@ numberf(char * buf, char * end, double num, int base, int size, int precision, i
return 0; return 0;
c = (type & ZEROPAD) ? '0' : ' '; c = (type & ZEROPAD) ? '0' : ' ';
sign = 0; sign = 0;
if (type & SIGN) {
if (num < 0) { if (num < 0) {
sign = '-'; sign = '-';
num = -num; num = -num;
@ -179,7 +178,6 @@ numberf(char * buf, char * end, double num, int base, int size, int precision, i
sign = ' '; sign = ' ';
size--; size--;
} }
}
if (type & SPECIAL) { if (type & SPECIAL) {
if (base == 16) if (base == 16)
size -= 2; size -= 2;
@ -231,11 +229,13 @@ numberf(char * buf, char * end, double num, int base, int size, int precision, i
++buf; ++buf;
} }
} }
if (type & ZEROPAD) {
while (i < precision--) { while (i < precision--) {
if (buf <= end) if (buf <= end)
*buf = '0'; *buf = '0';
++buf; ++buf;
} }
}
while (i-- > 0) { while (i-- > 0) {
if (buf <= end) if (buf <= end)
*buf = tmp[i]; *buf = tmp[i];