Skip to content
Search

Magic number

lastmod 2018-08-17created 2016-08-315 edits

In computer programming, the term magic number has multiple meanings.

About

It has the following meanings.

  • An integer or character value used to identify a file format or protocol.
  • A unique value with a specific meaning assigned to it. (e.g., Globally Unique Identifiers)
  • A constant that appears out of nowhere without explanation (a negative meaning)
  • A value repeated many times that could be replaced with a constant.

Magic GUIDs

It is possible to create or alter globally unique identifiers (GUIDs) so that they are memorable, but this is highly discouraged as it compromises their strength as near-unique identifiers.

Magic debug values

0xCCCCCCCC
Microsoft's C++ debugging runtime library and many DOS environments.
Used to mark uninitialized stack memory.
0xFDFDFDFD
Used by Microsoft's C/C++ debug malloc() function.
to mark "no man's land" memory guide band (guard bytes)1 before and after allocated heap memory.

Favorite site

References


  1. Values written before and after memory allocated on the heap. The debugger always watches these values, and if the memory in this guide band area is corrupted, it treats it as a heap crash and raises a runtime error. ↩