Post 001 · Reference
Numbers every coder runs into.
Some numbers show up in programming over and over. They aren't random: almost all of them are powers of two, minus one. Switch the base to see why.
Powers of two
computers count in binaryBits in a byte
The basic unit of memory. One byte can hold 28 = 256 different values.
27, written 10000000
A 1 followed by seven 0s in binary. It's the highest bit of a byte, and there are exactly 128 characters in ASCII (0–127).
Biggest value in one byte
Eight 1s: 11111111 = 0xFF. It's why RGB colors go from 0 to 255 and why #FFFFFF is white.
One kibibyte (KiB)
210. Close enough to 1,000 that people call it a “kilobyte,” which is why your 1 TB drive shows up as about 931 GB.
Max unsigned 16-bit integer
216 − 1. It's also the highest network port number, because ports are stored in 16 bits.
Try it · click any bit
The 32-bit integer limit
A signed 32-bit integer uses its first bit (outlined in red) for the sign. That leaves 31 bits for the value, so the max is 231 − 1 = 2,147,483,647. Add 1 and it overflows around to −2,147,483,648. Without a sign bit (unsigned), all 32 bits count, so the max is 4,294,967,295.
Signed (int32)
2,147,483,647
Unsigned (uint32)
2,147,483,647
Integer limits
where numbers overflowMax signed 8-bit integer
The range of a signed byte is −128 to 127. Fun fact: 127.0.0.1 is “localhost,” your own computer.
Max signed 32-bit integer
231 − 1, also called INT_MAX. This is the number that broke YouTube's view counter when “Gangnam Style” passed it in 2014.
Min signed 32-bit integer
One further from zero than the max, because zero takes up one of the “positive” slots.
Max unsigned 32-bit integer
232 − 1. It's also why 32-bit programs can only use about 4 GB of memory, and why there are only ~4.3 billion IPv4 addresses.
Max signed 64-bit integer
263 − 1. About 9.2 quintillion. That's long in Java and i64 in Rust. You'll basically never overflow it by counting.
JavaScript's max safe integer
253 − 1, or Number.MAX_SAFE_INTEGER. Above this, JS numbers lose precision: 2**53 + 1 === 2**53 is true.
Floats & text
numbers that look wrong0.1 + 0.2
Computers store decimals in binary, and 0.1 can't be written exactly in binary (like 1/3 in decimal). That's why you never compare money with floats.
not an integer · base switch skips itThe letter “A”
In ASCII, A is 65 and a is 97. They're exactly 32 apart, so flipping one bit changes the case.
Highest Unicode code point
U+10FFFF. Every character, emoji, and symbol in Unicode fits below this number.
Time & the web
numbers you'll see every dayThe Unix epoch
Most computers count time as seconds since midnight UTC on January 1, 1970. Right now that number is about 1.7 billion.
a date · base switch skips itThe Year 2038 problem
At 03:14:07 UTC that day, Unix time hits 2,147,483,647 seconds — the 32-bit limit. Systems that still store time as a signed 32-bit integer will roll over to 1901.
a date · base switch skips itNot Found
The most famous HTTP status code. 200 means OK, 301 means moved, 500 means the server broke.
The HTTPS port
Secure websites (like this one) talk on port 443. Plain HTTP uses port 80, and SSH uses 22.