magic number


Also found in: Dictionary, Thesaurus, Medical, Wikipedia.
Related to magic number: Golden number

magic number

(jargon, programming)
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 (hard-coded), 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 pseudorandom 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". Nowadays only a wizard knows the spells to create magic numbers. MS DOS executables begin with the magic string "MZ".

*The* magic number, on the other hand, is 7+/-2. The paper cited below 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.

["The magical number seven, plus or minus two: some limits on our capacity for processing information", George Miller, in the "Psychological Review" 63:81-97, 1956].

magic number

In programming, a magic number is a constant value used to identify a file format, protocol or error code. In many file formats, the first few bytes identify the file; for example, "PK" in ZIP files and the hex values "F8 D8" in JPEG files.

Certain communications protocols use a magic number, such as the hex values "63 82 53 63" at the start of every DHCP packet or "FF 53 4D 42" at the beginning of every SMB request. See DHCP and SMB.

Magic Constants
The term also refers to fixed values in a program that are never expected to change. For example, an algorithm involving playing cards might frequently use the magic constant "52" without jokers or "54" with two jokers (or "51" and "53" for offset addresses). If SizeofDeck = 52 were declared, the algorithm could be reprogrammed by changing the line of code to SizeofDeck = 54.
References in periodicals archive ?
Those who had already reached the magic number on this law's start date would not be immediately executed, but no addition to their existing score would be allowed otherwise there would be an immediate goodbye.
Now two scientists at Oregon State University in Corvallis have come up with a carbon structure that they believe may explain the magic numbers of the smaller clusters.
Clippers (42-30) update: The Clippers' magic number to clinch a playoff spot is four, the combined number of wins and New Orleans losses.
The Dow crossed its magic number of 10,000 on Thursday, and Mike Chrisman is here to tell you why and to offer a pair of recommendations that may help you to reach your financial goals.
com's DVD bestseller list and features 46 Schoolhouse Rock favorites, including "Conjunction Junction," "I'm Just a Bill" and "Three Is the Magic Number.
Although it looks like a formality, their magic number to clinch a playoff spot for the first time in nine years is five - the combined number of their wins and New Orleans losses.
Human adults can easily memorise up to seven figures, such as phone numbers and post codes - known as the magic number effect.
Next January we should reach the magic number of 10 million users, representing an important step for Copernic.
Jack Johnson and Friends: ``Sing-A-Longs and Lullabies for the Film Curious George'' (Brushfire) This 13-track soundtrack features eight Johnson originals, a cover of the White Stripes' ``We're Going to Be Friends,'' a take on the Schoolhouse Rock classic ``Three Is the Magic Number,'' as well as contributions by Ben Harper, G.
Though the magic number of $500 for price-per-line looms before us, it has not yet been met.
The veteran right-hander and free agent-to-be will start Sunday's season finale in San Diego only if it has a bearing on the National League West race, an unlikely proposition given that the Padres reduced their magic number for clinching the title to two by beating San Francisco.
According to Carol Cooper, associate publisher of Martindale-Hubbell, the magic number of 1 million searches in a month was reached in September.