~/bend-docscommunity

fixed64.bend fails

raw source on the hub · import 0x4e6a6615b0feb5ac27adea952228511e/fixed64.bend as Fixed64

lib/fixed64.bend -- Q8.56 signed fixed point on two U32 limbs.

An Fx is a 64-bit two's-complement integer (hi:lo) read as value / 2^56: range about +-128, resolution 2^-56 (1.4e-17), against F32's 24-bit mantissa. It is built only from U32 operations the GPU already has: 32x32 products are assembled from 16-bit halves (Fx.mul_hi), 64-bit carries come from sum < addend, and the escape test of a Mandelbrot loop is one comparison on the high limb. demos/mandelbrot/deep uses it to zoom past the point where F32 cannot even represent the centre.

Fx.mul truncates toward zero. Fx.div10 and Fx.shr are for non-negative values (the decimal parser and pixel geometry). The specification of every operation against the exact integers is stated as open claims in lib/claims/fixed64.bend, and tested against Python in lib/test_fixed64.py.

1 import
import Base