def veltkamp_split(x):

'Exact split into two 26-bit precision components'

t = x * 134217729.0

hi = t - (t - x)

lo = x - hi

return hi, lo

csclub.uwaterloo.ca/~pbarfuss/dekk…

^{}

Output: two signed 26-bit precision floats

Invariant: x == hi + lo

Constant: 134217729.0 == 2.0 ** 27 + 1.0

^{}

>>> hi, lo = veltkamp_split(pi)

>>> hi + lo == pi

True

>>> hi.hex()

'0x1.921fb58000000p+1'

>>> lo.hex()

'-0x1.dde9740000000p-26'

Note all the trailing zeros and the difference between the two exponents. Also both the lo and hi values are signed.

^{}

# Four exact components of e * pi:

>>> pi_hi*e_hi

8.539734226211163

>>> pi_hi*e_lo

7.207993525551209e-08

>>> pi_lo*e_hi

-7.561753118743836e-08

>>> pi_lo*e_lo

-6.382525038592985e-16

^{}

^{}

Answer: The extra bit is stored in the sign bit of the "lo" component.

53 bits + 1 sign = 26 bits + 1 sign + 26 bits + 1 sign

All bits accounted for.🧐

Cool!😏

^{}