|
|
@ -16,6 +16,7 @@ |
|
|
|
// Marcin Wojdyr
|
|
|
|
// Marcin Wojdyr
|
|
|
|
// Leonard Ritter
|
|
|
|
// Leonard Ritter
|
|
|
|
// Stefano Zanotti
|
|
|
|
// Stefano Zanotti
|
|
|
|
|
|
|
|
// Adam Allison
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// LICENSE:
|
|
|
|
// LICENSE:
|
|
|
|
//
|
|
|
|
//
|
|
|
@ -226,11 +227,18 @@ static stbsp__int32 stbsp__real_to_parts(stbsp__int64 *bits, stbsp__int32 *expo, |
|
|
|
|
|
|
|
|
|
|
|
static char stbsp__period = '.'; |
|
|
|
static char stbsp__period = '.'; |
|
|
|
static char stbsp__comma = ','; |
|
|
|
static char stbsp__comma = ','; |
|
|
|
static char stbsp__digitpair[201] = |
|
|
|
static struct |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
short temp; // force next field to be 2-byte aligned
|
|
|
|
|
|
|
|
char pair[201]; |
|
|
|
|
|
|
|
} stbsp__digitpair = |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
0, |
|
|
|
"00010203040506070809101112131415161718192021222324" |
|
|
|
"00010203040506070809101112131415161718192021222324" |
|
|
|
"25262728293031323334353637383940414243444546474849" |
|
|
|
"25262728293031323334353637383940414243444546474849" |
|
|
|
"50515253545556575859606162636465666768697071727374" |
|
|
|
"50515253545556575859606162636465666768697071727374" |
|
|
|
"75767778798081828384858687888990919293949596979899"; |
|
|
|
"75767778798081828384858687888990919293949596979899" |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
STBSP__PUBLICDEF void STB_SPRINTF_DECORATE(set_separators)(char pcomma, char pperiod) |
|
|
|
STBSP__PUBLICDEF void STB_SPRINTF_DECORATE(set_separators)(char pcomma, char pperiod) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -687,7 +695,7 @@ STBSP__PUBLICDEF int STB_SPRINTF_DECORATE(vsprintfcb)(STBSP_SPRINTFCB *callback, |
|
|
|
if (dp > 0) { |
|
|
|
if (dp > 0) { |
|
|
|
pr = (dp < (stbsp__int32)l) ? l - dp : 0; |
|
|
|
pr = (dp < (stbsp__int32)l) ? l - dp : 0; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
pr = -dp + ((pr > (stbsp__int32)l) ? l : pr); |
|
|
|
pr = -dp + ((pr > (stbsp__int32)l) ? (stbsp__int32) l : pr); |
|
|
|
} |
|
|
|
} |
|
|
|
goto dofloatfromg; |
|
|
|
goto dofloatfromg; |
|
|
|
|
|
|
|
|
|
|
@ -1047,7 +1055,7 @@ STBSP__PUBLICDEF int STB_SPRINTF_DECORATE(vsprintfcb)(STBSP_SPRINTFCB *callback, |
|
|
|
if ((fl & STBSP__TRIPLET_COMMA) == 0) { |
|
|
|
if ((fl & STBSP__TRIPLET_COMMA) == 0) { |
|
|
|
do { |
|
|
|
do { |
|
|
|
s -= 2; |
|
|
|
s -= 2; |
|
|
|
*(stbsp__uint16 *)s = *(stbsp__uint16 *)&stbsp__digitpair[(n % 100) * 2]; |
|
|
|
*(stbsp__uint16 *)s = *(stbsp__uint16 *)&stbsp__digitpair.pair[(n % 100) * 2]; |
|
|
|
n /= 100; |
|
|
|
n /= 100; |
|
|
|
} while (n); |
|
|
|
} while (n); |
|
|
|
} |
|
|
|
} |
|
|
@ -1445,7 +1453,7 @@ static stbsp__int32 stbsp__real_to_parts(stbsp__int64 *bits, stbsp__int32 *expo, |
|
|
|
*bits = b & ((((stbsp__uint64)1) << 52) - 1); |
|
|
|
*bits = b & ((((stbsp__uint64)1) << 52) - 1); |
|
|
|
*expo = (stbsp__int32)(((b >> 52) & 2047) - 1023); |
|
|
|
*expo = (stbsp__int32)(((b >> 52) & 2047) - 1023); |
|
|
|
|
|
|
|
|
|
|
|
return (stbsp__int32)(b >> 63); |
|
|
|
return (stbsp__int32)((stbsp__uint64) b >> 63); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static double const stbsp__bot[23] = { |
|
|
|
static double const stbsp__bot[23] = { |
|
|
@ -1655,7 +1663,7 @@ static stbsp__int32 stbsp__real_to_str(char const **start, stbsp__uint32 *len, c |
|
|
|
d = value; |
|
|
|
d = value; |
|
|
|
STBSP__COPYFP(bits, d); |
|
|
|
STBSP__COPYFP(bits, d); |
|
|
|
expo = (stbsp__int32)((bits >> 52) & 2047); |
|
|
|
expo = (stbsp__int32)((bits >> 52) & 2047); |
|
|
|
ng = (stbsp__int32)(bits >> 63); |
|
|
|
ng = (stbsp__int32)((stbsp__int64) bits >> 63); |
|
|
|
if (ng) |
|
|
|
if (ng) |
|
|
|
d = -d; |
|
|
|
d = -d; |
|
|
|
|
|
|
|
|
|
|
@ -1765,7 +1773,7 @@ static stbsp__int32 stbsp__real_to_str(char const **start, stbsp__uint32 *len, c |
|
|
|
} |
|
|
|
} |
|
|
|
while (n) { |
|
|
|
while (n) { |
|
|
|
out -= 2; |
|
|
|
out -= 2; |
|
|
|
*(stbsp__uint16 *)out = *(stbsp__uint16 *)&stbsp__digitpair[(n % 100) * 2]; |
|
|
|
*(stbsp__uint16 *)out = *(stbsp__uint16 *)&stbsp__digitpair.pair[(n % 100) * 2]; |
|
|
|
n /= 100; |
|
|
|
n /= 100; |
|
|
|
e += 2; |
|
|
|
e += 2; |
|
|
|
} |
|
|
|
} |
|
|
|