chickadee » fmt » fix

radix <k> <format> ...procedure
fix <k> <format> ...procedure

These alter the radix and fixed point precision of numbers output with dsp, wrt, pretty or num. These settings apply recursively to all output data structures, so that

(fmt #f (radix 16 '(70 80 90)))

will return the string "(#x46 #x50 #x5a)". Note that read/write invariance is essential, so for dsp, wrt and pretty the radix prefix is always included when not decimal. Use num if you want to format numbers in alternate bases without this prefix. For example,

(fmt #f (radix 16 "(" (fmt-join num '(70 80 90) " ") ")"))

would return "(46 50 5a)", the same output as above without the "#x" radix prefix.

Note that fixed point formatting supports arbitrary precision in implementations with exact non-integral rationals. When trying to print inexact numbers more than the machine precision you will typically get results like

(fmt #f (fix 30 #i2/3))

=> "0.666666666666666600000000000000"

but with an exact rational it will give you as many digits as you request:

(fmt #f (fix 30 2/3))

=> "0.666666666666666666666666666667"