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 binary
8

Bits in a byte

The basic unit of memory. One byte can hold 28 = 256 different values.

128

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).

255

Biggest value in one byte

Eight 1s: 11111111 = 0xFF. It's why RGB colors go from 0 to 255 and why #FFFFFF is white.

1,024

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.

65,535

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 overflow
127

Max 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.

2,147,483,647

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.

−2,147,483,648

Min signed 32-bit integer

One further from zero than the max, because zero takes up one of the “positive” slots.

4,294,967,295

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.

9,223,372,036,854,775,807

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.

9,007,199,254,740,991

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 wrong
0.30000000000000004

0.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 it
65

The letter “A”

In ASCII, A is 65 and a is 97. They're exactly 32 apart, so flipping one bit changes the case.

1,114,111

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 day
1970-01-01

The 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 it
2038-01-19

The 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 it
404

Not Found

The most famous HTTP status code. 200 means OK, 301 means moved, 500 means the server broke.

443

The HTTPS port

Secure websites (like this one) talk on port 443. Plain HTTP uses port 80, and SSH uses 22.