![A stick figure smiling](/images/welcome.jpg)
Here's a preview from my zine, How Integers and Floats Work! If you want to see more comics like this, sign up for my saturday comics newsletter or browse more comics!
![Image of a comic. To read the full HTML alt text, click "read the transcript".](/images/uploads/32-bit-small.png)
read the transcript!
panel 1: using 32-bit integers is dangerous
Let’s see some examples of how it can go wrong and why it’s almost always better to use 64-bit integers instead!
(32-bit floats are bad too, for similar reasons)
panel 2: 32 bit integers are at most 4 billion
unsigned 32-bit ints go from 0 to 4,294,967,295 (4 billion)
signed 32-bit ints go from -2,147,483,648 to 2,147,483,647
panel 3: times “4 billion” wasn’t enough
Database primary keys: 4 billion records really isn’t that much.
IPv4 addresses: turns out we want more than 4 billion computers on the internet. Oops.
Registers: in the 90s, registers were 32 bits. 4 billion bytes of RAM is 4GB. We need more than that.
Unix timestamps: 2 billion seconds after Jan 1, 1970 is Jan 19, 2038. That’s going to be an exciting day. (look up “2038 problem”!)
panel 4: 64 bits is usually big enough
For example, 2^64 seconds after Jan 1, 1970 is over 100 billion years in the future: well after the death of the sun.
So a 64-bit timestamp is definitely enough space.
panel 5: be wary of using 32-bit integers by accident
Systems that were designed in the 90s often have a 32-bit integer as the default.
For example, in MySQL an INTEGER is 32 bits.
Saturday Morning Comics!
Want another comic like this in your email every Saturday? Sign up here!