Copyright © Philip M. Parker, INSEAD. Terms of Use.

Definition: Magic Number |
Magic NumberNoun1. The atomic number of an extra stable strongly bound atomic nucleus: 2, 8, 20, 28, 50, 82 or 126. Source: WordNet 1.7.1 Copyright © 2001 by Princeton University. All rights reserved. |
| Domain | Definitions |
Computing | Magic number n. [Unix/C; common] 1. In source code, some non-obvious constant whose value is significant to the operation of a program and that is inserted inconspicuously in-line (hardcoded), rather than expanded in by a symbol set by a commented `#define'. Magic numbers in this sense are bad style. 2. A number that encodes critical information used in an algorithm in some opaque way. The classic examples of these are the numbers used in hash or CRC functions, or the coefficients in a linear congruential generator for pseudo-random numbers. This sense actually predates and was ancestral to the more common sense 1. 3. Special data located at the beginning of a binary data file to indicate its type to a utility. Under Unix, the system and various applications programs (especially the linker) distinguish between types of executable file by looking for a magic number. Once upon a time, these magic numbers were PDP-11 branch instructions that skipped over header data to the start of executable code; 0407, for example, was octal for `branch 16 bytes relative'. Many other kinds of files now have magic numbers somewhere; some magic numbers are, in fact, strings, like the `!' at the beginning of a Unix archive file or the `%!' leading PostScript files. Nowadays only a wizard knows the spells to create magic numbers. How do you choose a fresh magic number of your own? Simple -- you pick one at random. See? It's magic! _The_ magic number, on the other hand, is 7+/-2. See "The magical number seven, plus or minus two: some limits on our capacity for processing information" by George Miller, in the "Psychological Review" 63:81-97 (1956). This classic paper established the number of distinct items (such as numeric digits) that humans can hold in short-term memory. Among other things, this strongly influenced the interface design of the phone system. Source: Jargon File. |
Source: compiled by the editor from various references; see credits. | |
(From Wikipedia, the free Encyclopedia)
(From Wikipedia, the free Encyclopedia)
In computer programming, a magic number is a special constant used for some specific purpose.
An early convention in the UNIX operating system was that binary files started with two bytes containing a "magic number" identifying the type of the file. These were originally used by the UNIX linker and loader, but are now used by many other programs. In a wiggly hack, the very earliest magic numbers were PDP-11 branch instructions.
Unnamed magic numbers in source code are bad programming practice because they make the program harder to read, understand, and maintain. For example, if the below pseudocode snippet is supposed to iterate through the months of the year
If there is a desire to change the length of the buffers, changing code that contains many code snippets such as
...
for buf_index = 1 to NumberOfBuffers
for char_index = 1 to BufferSize
buffers[buf_index][char_index] = 0
Macro languages and the C preprocessor were developed for just this purpose. (From Wikipedia, the free Encyclopedia)
In sports, a magic number is a number used to indicate how close a front-running team is to clinching a season title. It is the total of additional wins by the front-running team, plus additional losses by the rival team, after which it is mathematically impossible for the rival team to capture the title.
A concise formula to calculate the magic number is:
Magic numbers in UNIX files
Magic numbers in code
for n = 1 to 12
is more difficult to elucidate the meaning of thanfor n = 1 to MonthsPerYear
They make changing the value of the magic number globally throughout the code much more difficult. If the magic number is named beforehand, the definition need merely be changed to affect the rest of the named constants. This is also important because a single number may have more than one meaning in a program. For example, the number '32' may be used to define a number of buffers used in a program, and also be chosen as the length of those buffers. for buf_index = 1 to 32
for char_index = 1 to 32
buffers[buf_index][char_index] = 0requires the editor to check each use of the number to see which sense it is meant in, whereas if the code reads define NumberOfBuffers 32
define BufferSize 32
it is easy to change the buffer size throughout the program by editing just one line of code. Magic number (sports)
magic number = G + 1 - WA - LB
WhereG is the total number of games in the season
WA is the number of wins team "A" has in the season
LB is the number of losses team "B" has in the season
For example, in Major League Baseball there are 162 games in a season. Suppose the standings are as follows:Team Wins Losses
"A" 96 58
"B" 92 62
Then the magic number for team "A" to win the division is 162 + 1 - 96 - 62 = 5, since any combination of wins by team "A" and losses by team "B", totalling to 5 make it is impossible for team "B" to win the division title.
Source: adapted by the editor from Wikipedia, the free encyclopedia under a copyleft GNU Free Documentation License (GFDL) from the article "Magic number."
Crosswords: Magic Number |
| Specialty definitions using "magic number": Devil and Dr. Faustus ♦ file signature ♦ hardcoded, hard-coded ♦ Portable Pixmap. (references) |
| Domain | Usage | |
Movie/TV Titles | Ten: The Magic Number (1973) | |
Source: compiled by the editor from various references; see credits. | ||
| The following statistics estimate the number of searches per day across the major English-language search engines as identified by various trade publications. Hyperlinks lead to commercial use of the expression at Amazon.com. |
| Expression | Frequency per Day |
magic number three | 7 |
bad magic number | 4 |
3 magic number | 4 |
magic number trick | 4 |
magic number port serial | 4 |
baseball magic number | 3 |
bad classformaterror magic number | 2 |
| Source: compiled by the editor from various references; see credits. | |
| Language | Translations for "magic number"; alternative meanings/domain in parentheses. | |
Japanese Kanji | マシン油 (barowner, machine oil, magic, magic glass, magic hand, magic ink marker, magic mirror, Magic Tape, magical, magician, majolica, Majorca, majority, manager, manipulator, mascara, mascot, masculine, mask, masker, masking, mass, mass communication, mass consumption, mass democracy, mass fashion, mass game, mass media, mass production, mass sales, mass screening, Masscomp, mast, master, master course, master file, master key, master plan, master tape, masterpiece, Masters Golf Tournament, masturbation, mazurka, muscat, mustard, proprietor, serious, to jerk off, to masturbate). (various references) | |
Japanese Katakana | マジックナンバー . (various references) | |
Pig Latin | agicmay umbernay.(various references) | |
| Source: compiled by the editor from various translation references. | ||
Scrabble® Enable2K-Verified Anagrams | |
| Words within the letters "a-b-c-e-g-i-m-m-n-r-u" | |
-2 letters: cambering, cumbering, embracing, germanium. | |
-3 letters: amercing, breaming, cramming, creaming, crumbing, embruing, geranium, germanic, incumber, manicure, rumbaing, umbering. | |
-4 letters: anergic, bamming, beaming, bearing, bracing, brucine, bumming, cambium, carbine, carmine, cranium, crummie, cumarin, curbing, gambier, gammier, germina, grimace, gummier, mangier, numeric, ramming, reaming, rummage, umbrage, unbrace, uraemic. | |
-5 letters: acumen, aecium, airmen, amebic, ammine, anemic, anuric, arcing, arming, bagmen, banger, baring, barium, barmen, barmie, begrim, binger, bregma, brucin, bummer, burnie, cabmen, cagier, camber, cangue, caribe, caring, carmen, carnie, cering, cerium, cinema, crambe, cringe, crinum, cubage, cubing, cueing, cumber, cummer, cummin, curiae, curing, earing, engram, enigma, erbium, gainer, gambir, gamier, gamine, gammer, german, graben, gramme, granum, guinea, gummer, iceman, imager, imbrue, immane, immune, immure, incage, macing, magnum, maigre, maimer, manger, manure, margin, marine, mauger, maugre, megrim, merman, mimbar, mincer, mirage, murein, murine, muring, neumic, number, racing, ragmen, reagin, regain, regina, regnum, remain, rubace, rumina, umbrae, unbear, uncage, unciae, uranic, urbane, uremia, uremic. | |
| Source: compiled by the editor from various references; see credits. SCRABBLE® is a registered trademark. All intellectual property rights in and to the game are owned in the U.S.A and Canada by Hasbro Inc., and throughout the rest of the world by J.W. Spear & Sons Limited of Maidenhead, Berkshire, England, a subsidiary of Mattel Inc. Mattel and Spear are not affiliated with Hasbro. | |
Hexadecimal (or equivalents, 770AD-1900s) (references)4D 61 67 69 63      4E 75 6D 62 65 72 |
| Leonardo da Vinci (1452-1519; backwards) (references)
|
Binary Code (1918-1938, probably earlier) (references)01001101 01100001 01100111 01101001 01100011 00100000 01001110 01110101 01101101 01100010 01100101 01110010 |
HTML Code (1990) (references)M a g i c   N u m b e r |
ISO 10646 (1991-1993) (references)004D 0061 0067 0069 0063      004E 0075 006D 0062 0065 0072 |
Encryption (beginner's substitution cypher): (references)47677375692488779687184 |
| 1. Definition 2. Crosswords 3. Usage: Modern 4. Expressions: Internet | 5. Translations: Modern 6. Anagrams 7. Orthography 8. Bibliography |
Copyright © Philip M. Parker, INSEAD. Terms of Use.