benilla-re systems structs docs

__fptostr

function · crt · primitive

Address
0x40fef9 · 119 bytes, up to 0x40ff6f
Signature
void __cdecl (char *buffer, int digits, _strflt *flt)
Meaning
Writes digits of a mantissa text padded with 0 and rounds half up on the next byte, a carry raising decpt
Confidence
verified, proof one
Name from
the community database (idb)
Finding
crt/printf#rounding-the-digit-text
Test
crt::crt_sprintf_float_difftest

Finding: Rounding the digit text in crt: formatted output

_fptostr writes 0 and then n digits of the mantissa text, 0 once the text runs out. For n of 0 or more, when the next mantissa byte is 5 or above as a signed byte, it adds one at the last digit, nines becoming zeros as the carry moves left. A carry into the leading 0 makes it 1 and adds one to the decimal exponent; otherwise the leading 0 is removed. The mantissa of a non-finite value is its text, so %.2f of +∞ rounds I up: 1.#J. For n below 0 the result is empty. __shift moves a string up by n bytes, its NUL included, and does nothing for 0.

The derivation is in the doc.

Callers 3

Callees 2

Calls and jumps by a bare address, from tables/calls.tsv.