Alan Freedman -- The Computer Language Company - Computer Desktop Encyclopedia
Computer Desktop Encyclopedia
Longest-Running Tech Reference on the Planet

A CDE Definition

You'll love The Computer Desktop Encyclopedia (CDE) for Tech Term of the Day (TTOD)


magic constant

See magic number.

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.

Personal Use Only

Before/After Your Search Term
MAE-Centralmagic cookie
MAE-EastMagic Link
MAE-WestMagic Mouse
Maemomagic number
MaestroMagic Trackpad
magazine style columnsMagicMouse
MagicMagnavox Odyssey
Magic Capmagnetic card

Terms By Topic
Click any of the following categories for a list of fundamental terms.
Computer Words You Gotta KnowSystem design
Job categoriesUnix/Linux
Interesting stuffPersonal computers
InternetIndustrial Automation/Process Control
Communications & networkingAssociations/Standards organizations
HistoryDesktop publishing
ProgrammingHealthcare IT
System design