Michael Chaney Profile picture
Feb 11 1 tweets 2 min read Read on X
As a programmer, there are a bunch of numbers that you should intuitively know. There are so many, but a few that are handy to know follow.

All powers of 2 of up to 2^16:
1, 2, 4, 8, 16, 32,64, 128, 256, 512, 1024, 2048, 4096, 8192, 16,384, 32,768, 65,536

All powers of 2 up to 2^16, minus 1:
0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16,383, 32,767, 65,535

Approximations of 2 ^ (multiples of 10):
2 ^ 10 ~ 1000 (1024 == "1K")
2 ^ 20 ~ 1,000,000 (1,048,576 == "1M")
2 ^ 30 ~ 1,000,000,000 (1,073,741,824 == "1G")

Some powers of 2, times 3:
32 * 3 = 96
64 * 3 = 192
256 * 3 = 768

Numbers of seconds:
60 - one minute
3600 - one hour
86,400 - one day
604,800 - one week
31,536,000 - one year (365 days)

The Sumerians apparently had a base 60 number system. 60 is an awesome number with factors of 2, 3, 4, 5, 6, 10, 12, 15, 20, and 30. It can be evenly divided in a lot of convenient ways.

Numbers of hours:
24 - one day
168 - one week
8760 - one year (365 days)

Weird numbers that pop up here and there in video settings:
640 - 128 x 5
480 - 640 x 3/4
1280 - 640 x 2
720 - 360 x 2, but also 1280 x 9/16 (note that 9/16 is 3/4 squared)
1920 - 640 x 3
1080 - 360 x 3 (1920x1080 are the standard "1080p" or "Full HD" resolution)

I recommend using constants or something descriptive for these instead of just putting these raw numbers in your code. However, it's useful when debugging to see "86400" and automatically say "Hmm, that's how many seconds are in a day".

I saw a news story about a software bug - don't remember which one - but the journalist mentioned that the issue occurred at the seemingly random number of "256". Again, it's obvious to us that it's a byte overflow error.

Any others you can think of?

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Michael Chaney

Michael Chaney Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(