I10_OUTPUT
function · crt · primitive
- Address
0x4116fd· 659 bytes, up to0x41198f- Signature
int __cdecl (Ld10Real value, int ndigits, uint32_t flags, _FloatOutStruct *fos)- Meaning
- Writes up to 21 decimal digits of an 80-bit real by 12-byte arithmetic, rounding on one more digit
- Confidence
- verified, proof one
- Finding
- crt/decimal#making-the-digits
- Test
crt::crt_i10_output_difftest,crt::crt_sprintf_float_difftest
Finding: Making the digits in crt: decimal digits
For a finite nonzero value, I10_OUTPUT estimates the decimal exponent r, scales the
magnitude by 10^-r, and when that is 1 or more adds one to r and multiplies by 0.1 truncated to
80 bits. The digit count is ndigits, plus r with bit 0 of flags (then 0 or less is the zero),
at most 21. It makes one digit more than the count, each the integer part of ten times the
remaining fraction. A last digit of 5 or more adds one to the digit before it, nines carrying; a
carry out of the first makes it 1 and raises the exponent. Otherwise trailing zeros go, and
none left is the zero.
The derivation is in the doc.
Callers 1
- __fltout2 crt
Callees 5
- ___add_12 crt
- ___shl_12 crt
- ___shr_12 crt
- ___ld12mul crt
- ___multtenpow12 crt
Calls and jumps by a bare address, from tables/calls.tsv.