How Good Is 64-bit Π? Hella

In [1]:
import ctypes as c
from math import pi as π

The smallest deviations from 64 bit π [π+δ, π, π-δ]:

In [2]:
['{0:.60f}'.format(
        c.c_double.from_buffer(c.c_long(c.c_long.from_buffer(c.c_double(π)).value + x)).value
    ) for x in [1,0,-1]]
Out[2]:
['3.141592653589793560087173318606801331043243408203125000000000',
 '3.141592653589793115997963468544185161590576171875000000000000',
 '3.141592653589792671908753618481568992137908935546875000000000']

Again in binary [π+δ, π, π-δ]:

In [3]:
[bin(c.c_long.from_buffer(c.c_double(π)).value + x) for x in [1,0,-1]]
Out[3]:
['0b100000000001001001000011111101101010100010001000010110100011001',
 '0b100000000001001001000011111101101010100010001000010110100011000',
 '0b100000000001001001000011111101101010100010001000010110100010111']

Closer numbers to π don't exist in 64 bits:

In [4]:
3.1415926535897934
Out[4]:
3.1415926535897936

In-between numbers are repeats from above:

In [5]:
['{0:.60f}'.format(x) for x in [3.1415926535897932, 3.1415926535897927]]
Out[5]:
['3.141592653589793115997963468544185161590576171875000000000000',
 '3.141592653589792671908753618481568992137908935546875000000000']

The circumference of Earth's orbit around the Sun in inches with the various π deviants:

In [6]:
['{0:,.10f}'.format(d) for d in [2*myπ*93*10**6*5280*12 for myπ in 
[c.c_double.from_buffer(c.c_long(c.c_long.from_buffer(c.c_double(π)).value + x)).value
    for x in [1,0,-1]]]]
Out[6]:
['37,023,543,758,849.5703125000',
 '37,023,543,758,849.5625000000',
 '37,023,543,758,849.5625000000']

A small fraction of an inch error on 584 million miles.