Skip to content

Instantly share code, notes, and snippets.

@jrg94 jrg94/LightDistanceCalc.md
Last active Dec 19, 2016

Embed
What would you like to do?
An example of the difference between a 32-bit and 64-bit integer.

Light Distance Calculation: 32-bit vs. 64-bit

Some Facts

Maximum Positive Signed 32-bit Integer: (2^31) - 1 = 2,147,483,647

Maximum Positive Signed 64-bit Integer: (2^63) - 1 = 9,223,372,036,854,775,807

Speed of Light: 299,792,458 m/s

If an integer were tracking meters in real time:

32-bit Calculation

In seconds: 2,147,483,638 m / 299,792,458 m/s = 7.16323436662 s

64-bit Calculation

In seconds: 9,223,372,036,854,775,807 m / 299,792,458 m/s = 30,765,857,481.5 s

In minutes: 30,765,857,481.5 s / 60 s/min = 512,764,291.358 mins 

In hours: 512,764,291.358 mins / 60 mins/hour = 8,546,071.52264 hours 

In days: 8,546,071.52264 hours / 24 hours/day = 356,086.313443 days 

In years: 356,086.313443 days / 365.25 days/year = 974.911193547 years

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.