mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
Cleaner, more general exponent output.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42690 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a11ef82207
commit
92f7e8d925
@ -252,32 +252,33 @@ namespace {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write out a decimal exponent. */
|
/* Write out an unsigned decimal integer. */
|
||||||
static char *
|
static char *
|
||||||
writeDecimalExponent (char *dst, int exponent)
|
writeUnsignedDecimal (char *dst, unsigned int n)
|
||||||
{
|
{
|
||||||
assert (exponent >= -65536 && exponent <= 65535);
|
char buff[40], *p;
|
||||||
|
|
||||||
if (exponent < 0) {
|
p = buff;
|
||||||
|
do
|
||||||
|
*p++ = '0' + n % 10;
|
||||||
|
while (n /= 10);
|
||||||
|
|
||||||
|
do
|
||||||
|
*dst++ = *--p;
|
||||||
|
while (p != buff);
|
||||||
|
|
||||||
|
return dst;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Write out a signed decimal integer. */
|
||||||
|
static char *
|
||||||
|
writeSignedDecimal (char *dst, int value)
|
||||||
|
{
|
||||||
|
if (value < 0) {
|
||||||
*dst++ = '-';
|
*dst++ = '-';
|
||||||
exponent = -exponent;
|
dst = writeUnsignedDecimal(dst, -(unsigned) value);
|
||||||
}
|
} else
|
||||||
|
dst = writeUnsignedDecimal(dst, value);
|
||||||
if (exponent == 0) {
|
|
||||||
*dst++ = '0';
|
|
||||||
} else {
|
|
||||||
char buff[12], *p;
|
|
||||||
|
|
||||||
p = buff;
|
|
||||||
while (exponent) {
|
|
||||||
*p++ = '0' + exponent % 10;
|
|
||||||
exponent /= 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
do
|
|
||||||
*dst++ = *--p;
|
|
||||||
while (p != buff);
|
|
||||||
}
|
|
||||||
|
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
@ -1865,7 +1866,7 @@ APFloat::convertNormalToHexString(char *dst, unsigned int hexDigits,
|
|||||||
/* Finally output the exponent. */
|
/* Finally output the exponent. */
|
||||||
*dst++ = upperCase ? 'P': 'p';
|
*dst++ = upperCase ? 'P': 'p';
|
||||||
|
|
||||||
return writeDecimalExponent (dst, exponent);
|
return writeSignedDecimal (dst, exponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
// For good performance it is desirable for different APFloats
|
// For good performance it is desirable for different APFloats
|
||||||
|
Loading…
Reference in New Issue
Block a user