Just as Chalice has a fairly broad selection of integral types, it also has a broad selection of fixed-point types. For the uninitiated, fixed-point arithmetic is like a cross between floating-point and integral arithmetic. Essentially, fixed-point arithmetic involves interpreting integers as being multiples of some value much smaller than 1.
For example:
uwrap16can represent any number between0x0000and0xffff(inclusive) with a precision of0x0001.0x1d9fcan be represented, but0x1d.9fcannot.ufix8_8can represent any number between0x00.00and0xff.ff(inclusive) with a precision of0x00.01.0x1d.9fcan be represented, but0x1d.9fb2cannot.
At each size there is every combination of frac and fix; signed and unsigned; wrapping, saturating and undefined-on-overflow.
They are specified by a particular combination of (w|s|)frac_M, u(w|s|)frac_N, u(w|s|)fixN_N or (w|s|)fixM_N, where s
is the size of the type in bits, n = s/2 and m = n - 1.
For example:
uwfrac_32is a 32-bit unsigned wrap-on-overflow fixed-point type that can represent any number between0x0.00000000(0) and0x.ffffffff(approximately 2.3283064e-10).sfix15_16is a 32-bit signed saturate-on-overflow fixed-point type that can represent any number between-0x8000.0000(-32768) and0x7fff.ffff(32767.9999847).frac_7is an 8-bit signed undefined-on-overflow fixed-point type that can represent any number between-0x.80(-0.5 = -128/256) and0x.7f(0.49609375 = 127/256).ufix4_4is an 8-bit unsigned undefined-on-overflow fixed-point type that can represent any number between0x0.0(0) and0xf.f(15.9375 = 15 + 15/16 = 255/16).