Skip to main content
← PSoXide SDK guides and examples · SDK f2fec1c301f1 · All Cargo features enabled; check feature gates before use.

Module fmt

Module fmt 

Source
Expand description

Integer-to-decimal ASCII without core::fmt.

core::fmt drags kilobytes of formatting machinery into a guest binary, so every project that draws a score, a coordinate, or a cell value with psx-font grew its own digit loop (gh-psx u32_dec, PSXcel write_dec / write_u64, hl-psx fmt_i32, VoXide Decimal3, the magikarp example). This module is that loop, once.

Each function renders right-to-left into a scratch tail of buf, then returns the &str covering just the digits. Size buf with the matching *_DEC_MAX constant and it can never fail; an undersized buffer panics (slice bounds), which the guest panic handler reports with file:line.

Constants§

I32_DEC_MAX
Maximum bytes i32_dec can produce (sign + 10 digits).
U32_DEC_MAX
Maximum bytes u32_dec can produce (u32::MAX = 10 digits).
U64_DEC_MAX
Maximum bytes u64_dec can produce (u64::MAX = 20 digits).

Functions§

i32_dec
Format v as decimal ASCII into buf, returning the digits as &str.
u32_dec
Format v as decimal ASCII into buf, returning the digits as &str.
u64_dec
Format v as decimal ASCII into buf, returning the digits as &str.