IT lexicon › Programming › Magic number

Magic number

Programming På svenska → Updated: 2026-05-24

Unexplained numeric constant in the middle of code — if (status == 17). A classic code smell.

Fix: named constant (const STATUS_REJECTED = 17). Better: enum. Also a technical term: bytes at the start of a file that identify the format (PNG magic: 89 50 4E 47, JPEG: FF D8).

← Back to the lexicon