benilla-re systems structs docs

__store_num

function · crt · primitive

Address
0x413a0e · 111 bytes, up to 0x413a7c
Signature
void __cdecl (int32_t n, uint32_t digits, char **out, uint32_t *left)
Meaning
Writes a number's last digits zero-padded, or its own with __no_lead_zeros; too little room ends the output
Confidence
verified, proof one
Name from
the community database (idb)
Finding
crt/time#writing-numbers-and-strings
Test
crt::crt_strftime_difftest, crt::crt_strftime_patterns_difftest

Finding: Writing numbers and strings in crt: calendar time

__store_str copies a string's bytes while room is left. Without __no_lead_zeros, __store_num writes exactly the count of the number's last digits, zero-padded, when the count is below the room, and otherwise sets the room to 0, which ends the format. With it, __store_number writes the digits low first while more than one byte of room is left, stopping after a quotient of 0 or less, then reverses them by a loop that swaps before it tests: with room for no digit it swaps the last byte written with the one after it, so the output ends in whatever the buffer held there. A digit is '0' plus the signed remainder: a negative number gives bytes below '0'.

The derivation is in the doc.

Callers 1

Callees 1

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