Posted by ColinWright 10/26/2025
How do you get around limitations like that in science?
>>> from fractions import Fraction
>>> f = Fraction(0xFEDCBA987654321, 0x123456789ABCDEF)
>>> f%1
Fraction(1, 5465701947765793)
>>> f - f%1
Fraction(14, 1)
That shows that 0xFEDCBA987654321 / 0x123456789ABCDEF = 14 + 1/5465701947765793 exactly. >>> math.log(5465701947765793, 2)
52.279328213174445
Shows that the denominator requires 52 bits which is slightly more than the number of mantissa bits in a 64-bit floating point number, so the result gets rounded to 14.0 due to limited precision.You can use special libraries for floating point that uses more mantisa.
In most sciences, numbers are never integers anyway, so you have errors intervals in the numerator and denumerator and you get an error interval for the result.
> 0xFEDCBA987654321 / 0x123456789ABCDEF
(somehow I'd seen the denotation for years yet never actually known what it was).
but i still wonder if there is something like OEIS for observations / analysis like this
Okay. Try this (in a Python terminal session):
>>> 111111111 ** 2
12345678987654321
(typo corrected)