fix DEBUG decimal() of negative number
This commit is contained in:
parent
c8f7b1b72c
commit
ad1c0f578e
@ -116,7 +116,7 @@ decimal(int x, char *ptr, int n)
|
||||
{
|
||||
if (x < 0) {
|
||||
x = -x;
|
||||
*ptr++ = '-'; ++n;
|
||||
*ptr = '-'; ++n;
|
||||
}
|
||||
return unsimal(x, ptr, n);
|
||||
}
|
||||
|
||||
@ -61,8 +61,8 @@ static int
|
||||
decimal(int x, char *ptr, int n)
|
||||
{
|
||||
if (x < 0) {
|
||||
*ptr++ = '-'; ++n;
|
||||
x = -x;
|
||||
*ptr = '-'; ++n;
|
||||
}
|
||||
return unsimal(x, ptr, n);
|
||||
}
|
||||
|
||||
@ -111,8 +111,8 @@ unsimal(unsigned x, char *ptr, int n)
|
||||
{
|
||||
if (10<=x) {
|
||||
unsigned const q = div10(x);
|
||||
n = unsimal(q, ptr, n);
|
||||
x -= 10 * q;
|
||||
n = unsimal(q, ptr, n);
|
||||
}
|
||||
ptr[n] = '0' + x;
|
||||
return 1+ n;
|
||||
@ -122,8 +122,8 @@ static int
|
||||
decimal(int x, char *ptr, int n)
|
||||
{
|
||||
if (x < 0) {
|
||||
*ptr++ = '-'; ++n;
|
||||
x = -x;
|
||||
*ptr = '-'; ++n;
|
||||
}
|
||||
return unsimal(x, ptr, n);
|
||||
}
|
||||
|
||||
@ -61,8 +61,8 @@ static int
|
||||
decimal(int x, char *ptr, int n)
|
||||
{
|
||||
if (x < 0) {
|
||||
*ptr++ = '-'; ++n;
|
||||
x = -x;
|
||||
*ptr = '-'; ++n;
|
||||
}
|
||||
return unsimal(x, ptr, n);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user