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,18 +167,16 @@ 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; size--;
size--; } else if (type & PLUS) {
} else if (type & PLUS) { sign = '+';
sign = '+'; size--;
size--; } else if (type & SPACE) {
} else if (type & SPACE) { sign = ' ';
sign = ' '; size--;
size--;
}
} }
if (type & SPECIAL) { if (type & SPECIAL) {
if (base == 16) if (base == 16)
@ -231,10 +229,12 @@ numberf(char * buf, char * end, double num, int base, int size, int precision, i
++buf; ++buf;
} }
} }
while (i < precision--) { if (type & ZEROPAD) {
if (buf <= end) while (i < precision--) {
*buf = '0'; if (buf <= end)
++buf; *buf = '0';
++buf;
}
} }
while (i-- > 0) { while (i-- > 0) {
if (buf <= end) if (buf <= end)