Fixed-point arithmetic on plain integers: a value is a number times 2^k, k stated at each call, and products and quotients are exact through 64 bits on any word. x/num/fixed-literal adds a reader literal for the values, 0.75q16.
fixed*The product of two fixed-point values, exact through its 64 bits and shifted down.
Returns: INTEGER — a times b over 2^k, rounded down; the caller keeps it within 32 bits
Examples:
(do (import x/num/fixed fixed*) (fixed* 98304 163840 16)) => 245760fixed/The quotient of two fixed-point values, the dividend shifted up through 64 bits first.
Returns: INTEGER — a times 2^k over b, rounded toward zero; the caller keeps it within 32 bits
Examples:
(do (import x/num/fixed fixed/) (fixed/ 98304 163840 16)) => 39321fixed*/A value scaled by a ratio, the product exact through its 64 bits.
Returns: INTEGER — a times b over c, rounded toward zero; the caller keeps it within 32 bits
Examples:
(do (import x/num/fixed fixed*/) (fixed*/ 1000000 44100 1000)) => 44100000fixed-ratioA ratio as a fixed-point value.
Returns: INTEGER — n over d as a fixed-point value of k fraction bits, rounded to the nearest
Examples:
(do (import x/num/fixed fixed-ratio) (fixed-ratio 3 4 16)) => 49152fixedA whole number as a fixed-point value.
Returns: INTEGER — n as a fixed-point value of k fraction bits
Examples:
(do (import x/num/fixed fixed) (fixed 3 16)) => 196608fixed-floorA fixed-point value’s whole part, rounded down.
Returns: INTEGER — The whole number at or below v
Examples:
(do (import x/num/fixed fixed-floor) (fixed-floor -98304 16)) => -2fixed-roundA fixed-point value rounded to the nearest whole number.
Returns: INTEGER — The whole number nearest v, a half going up
Examples:
(do (import x/num/fixed fixed-round) (fixed-round 98304 16)) => 2fixed-clampA value held within two bounds.
Returns: INTEGER — v, or the bound it passed
Examples:
(do (import x/num/fixed fixed-clamp) (fixed-clamp 40000 -32768 32767)) => 32767