Magic Numbers - Seven.JS
Notable Magic Numbers
As a magic number can show up in a project out of magic, new magic numbers appear every day. There are lots of magic numbers out there. Some say there are more magic numbers than regular numbers. The magic numbers that show up in a program have varying effects on it.
- The number 7 is the most well-known and most powerful number, as it helps prevent the accidental creation of zero-day bugs.
- The number 13 is associated with projects that get rushed, then get delayed, then get released to poor reviews, then get patched and then get even worse reviews
- 80 is a magic number that makes developers work late on Fridays. This number should be avoided at all costs
- A range of the digits of pi tends to show up as a magic number even though the constant is obviously available from the standard library.
- The constant 0x5F3759DF is used to compute a fast inverse square root
- Number %magic%, the most mysterious magic number, is believed to %fix% heisenbugs
- 3.000000001, we thought this number only appeared in floating point calculations
- We found number 57 in the production code and we don't know what it does, so there's that. #wontfix
- The other day I went to the grocery store at 7 AM to buy 7 oranges, but they were out of oranges so I bought 7 apples. Within 7 weeks, I ate all the apples. Wait, are we supposed to accept input?
- 1000, used as the default size of a static array
- The number 0.5 is used alongside Math.random() to implement 50/50 chance.
- The number 1, but we have since eliminated all instances of it via Find and Replace
Every project has LUK
There is a secret number that influences every project, regardless of how many magic numbers it contains. This number is what we call LUK. It influences the effect of other numbers, causing some non-magic numbers to have magical effects.
Project LUK Magic Number Outcome
37 89 The project will not build
797 257 The project will only run on your computer and not anyone else's
666 666 Classified
345 882 Segmentation fault (core dumped)
256 257 100% increased chance of integer overflow
16 16.00000001 100% increased chance of array index out of bounds exception