Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Magic number (programming)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Sequence of bytes used to identify or indicate the format of a file}} {{Use dmy dates|date=July 2019|cs1-dates=y}} In [[computer programming]], a '''magic number''' is any of the following: * A unique value with unexplained meaning or multiple occurrences which could (preferably) be replaced with a named constant * A constant numerical or text value used to identify a [[file format]] or protocol {{crossref|(for files, see [[List of file signatures]]}}) * A distinctive unique value that is unlikely to be mistaken for other meanings (e.g., [[Universally unique identifier|Universally Unique Identifiers]]) == Unnamed numerical constants == The term '''''magic number''''' or '''''magic constant''''' refers to the [[anti-pattern]] of using numbers directly in source code. This breaks one of the oldest rules of programming, dating back to the [[COBOL]], [[FORTRAN]] and [[PL/1]] manuals of the 1960s.<ref name="MartinG25">{{cite book |title=Clean Code - A handbook of agile software craftsmanship |url=https://archive.org/details/cleancodehandboo00mart_843 |url-access=limited |last=Martin |first=Robert C. |date=2009 |publisher=Prentice Hall |location=Boston |isbn=978-0-13-235088-4 |page=[https://archive.org/details/cleancodehandboo00mart_843/page/n330 300] |chapter= Chapter 17: Smells and Heuristics - G25 Replace Magic Numbers with Named Constants }}</ref> In the following example that computes the price after tax, <code>1.05</code> is considered a magic number: price_tax = 1.05 * price The use of unnamed magic numbers in code obscures the developers' intent in choosing that number,<ref name="MartinG16">{{cite book |title=Clean Code - A handbook of agile software craftsmanship |url=https://archive.org/details/cleancodehandboo00mart_843 |url-access=limited |last=Martin |first=Robert C. |year=2009 |publisher=Prentice Hall |location=Boston |isbn=978-0-13-235088-4 |page=[https://archive.org/details/cleancodehandboo00mart_843/page/n325 295] |chapter= Chapter 17: Smells and Heuristics - G16 Obscured Intent}}</ref> increases opportunities for subtle errors, and makes it more difficult for the program to be adapted and extended in the future.<ref>{{cite web |url=http://www.datamation.com/columns/article.php/3789981/Bjarne-Stroustrup-on-Educating-Software-Developers.htm |title=Bjarne Stroustrup on Educating Software Developers |first=James |last=Maguire |date=9 December 2008 |website=Datamation.com |url-status=dead |archive-url=https://web.archive.org/web/20180623112852/http://www.datamation.com/columns/article.php/3789981/Bjarne-Stroustrup-on-Educating-Software-Developers.htm |archive-date=23 June 2018}}</ref> As an example, it is difficult to tell whether every digit in <code>[[Pi|3.14159265358979323846]]</code> is correctly typed, or if the constant can be truncated to <code>3.14159</code> without affecting the functionality of the program with its reduced precision. Replacing all significant magic numbers with named [[constant (programming)|constant]]s (also called explanatory variables) makes programs easier to read, understand and maintain.<ref>{{cite web |url=http://www.ibm.com/developerworks/linux/library/l-clear-code/?ca=dgr-FClnxw01linuxcodetips |title=Six ways to write more comprehensible code |first=Jeff |last=Vogel |date=29 May 2007 |website=IBM Developer |archive-url=https://web.archive.org/web/20180926205449/https://www.ibm.com/developerworks/linux/library/l-clear-code/?ca=dgr-FClnxw01linuxcodetips |archive-date=26 September 2018 |url-status=dead }}</ref> The example above can be improved by adding a descriptively named variable: TAX = 0.05 price_tax = (1.0 + TAX) * price Names chosen to be meaningful in the context of the program can result in code that is more easily understood by a maintainer who is not the original author (or even by the original author after a period of time).<ref name="Paul_2002_SYMBOLS"/> An example of an uninformatively named constant is <code>int SIXTEEN = 16</code>, while <code>int NUMBER_OF_BITS = 16</code> is more descriptive. The problems associated with magic 'numbers' described above are not limited to numerical types and the term is also applied to other data types where declaring a named constant would be more flexible and communicative.<ref name="MartinG25"/> Thus, declaring <code>const string testUserName = "John"</code> is better than several occurrences of the 'magic value' <code>"John"</code> in a [[Test-driven development|test suite]]. === Random shuffle example === For example, if it is required to randomly shuffle the values in an array representing a standard pack of [[playing cards]], this [[pseudocode]] does the job using the [[FisherβYates shuffle]] algorithm: '''for''' i '''from''' 1 '''to''' 52 j := i + randomInt(53 - i) - 1 a.swapEntries(i, j) where <code>a</code> is an array object, the function <code>randomInt(x)</code> chooses a random integer between 1 and ''x'', inclusive, and <code>swapEntries(i, j)</code> swaps the ''i''th and ''j''th entries in the array. In the preceding example, <code>52</code> and <code>53</code> are magic numbers, also not clearly related to each other. It is considered better programming style to write the following: ''int'' deckSize:= 52 '''for''' i '''from''' 1 '''to''' deckSize j := i + randomInt(deckSize + 1 - i) - 1 a.swapEntries(i, j) This is preferable for several reasons: * '''Better readability'''. A programmer reading the first example might wonder, ''What does the number 52 mean here? Why 52?'' The programmer might infer the meaning after reading the code carefully, but it is not obvious.<ref name="Paul_2002_SYMBOLS"/> Magic numbers become particularly confusing when the same number is used for different purposes in one section of code. * '''Easier to maintain'''. It is easier to alter the value of the number, as it is not duplicated. Changing the value of a magic number is error-prone, because the same value is often used several times in different places within a program.<ref name="Paul_2002_SYMBOLS"/> Also, when two semantically distinct variables or numbers have the same value they may be accidentally both edited together.<ref name="Paul_2002_SYMBOLS"/> To modify the first example to shuffle a [[Tarot]] deck, which has 78 cards, a programmer might naively replace every instance of 52 in the program with 78. This would cause two problems. First, it would miss the value 53 on the second line of the example, which would cause the algorithm to fail in a subtle way. Second, it would likely replace the characters "52" everywhere, regardless of whether they refer to the deck size or to something else entirely, such as the number of weeks in a Gregorian calendar year, or more insidiously, are part of a number like "1523", all of which would introduce bugs. By contrast, changing the value of the <code>deckSize</code> variable in the second example would be a simple, one-line change. * '''Encourages documentation'''.<ref name="Paul_2002_SYMBOLS"/> The single place where the named variable is declared makes a good place to document what the value means and why it has the value it does. Having the same value in a plethora of places either leads to duplicate comments (and attendant problems when updating some but missing some) or leaves no ''one'' place where it's both natural for the author to explain the value and likely the reader shall look for an explanation. * '''Coalesces information'''. The declarations of "magic number" variables can be placed together, usually at the top of a function or file, facilitating their review and change.<ref name="Paul_2002_SYMBOLS"/> * '''Detects [[typo]]s'''. Using a variable (instead of a literal) takes advantage of a compiler's checking. Accidentally typing "62" instead of "52" would go undetected, whereas typing "<code>dekSize</code>" instead of "<code>deckSize</code>" would result in the compiler's warning that <code>dekSize</code> is undeclared. * '''Reduces typings'''. If a [[Integrated development environment|IDE]] supports [[code completion]], it will fill in most of the variable's name from the first few letters. * '''Facilitates parameterization'''. For example, to generalize the above example into a procedure that shuffles a deck of any number of cards, it would be sufficient to turn <code>deckSize</code> into a parameter of that procedure, whereas the first example would require several changes. '''function''' shuffle ('''int''' deckSize) '''for''' i '''from''' 1 '''to''' deckSize j := i + randomInt(deckSize + 1 - i) - 1 a.swapEntries(i, j) Disadvantages are: * '''Breaks locality'''. When the named constant is not defined near its use, it hurts the locality, and thus comprehensibility, of the code. Putting the 52 in a possibly distant place means that, to understand the workings of the "for" loop completely (for example to estimate the run-time of the loop), one must track down the definition and verify that it is the expected number. This is easy to avoid (by relocating the declaration) when the constant is only used in one portion of the code. When the named constant is used in disparate portions, on the other hand, the remote location is a clue to the reader that the same value appears in other places in the code, which may also be worth looking into. * '''Causes verbosity'''. The declaration of the constant adds a line. When the constant's name is longer than the value's, particularly if several such constants appear in one line, it may make it necessary to split one logical statement of the code across several lines. An increase in verbosity may be justified when there is some likelihood of confusion about the constant, or when there is a likelihood the constant may need to be changed, such as [[code reuse|reuse]] of a shuffling routine for other card games. It may equally be justified as an increase in expressiveness. * '''Performance considerations'''. It may be slower to process the expression <code>deckSize + 1</code> at run-time than the value "53". That being said, most modern compilers will use techniques like [[constant folding]] and [[loop optimization]] to resolve the addition during compilation, so there is usually no or negligible speed penalty compared to using magic numbers in code. Especially the cost of debugging and the time needed trying to understand non-explanatory code must be held against the tiny calculation cost. === Accepted uses {{anchor|Accepted limited use of magic numbers}} === {{More citations needed section|date=March 2010}} In some contexts, the use of unnamed numerical constants is generally accepted (and arguably "not magic"). While such acceptance is subjective, and often depends on individual coding habits, the following are common examples: * the use of 0 and 1 as initial or incremental values in a [[for loop]], such as {{code|2=cpp|1=for (int i = 0; i < max; i += 1)}} * the use of 2 to check whether a number is even or odd, as in <code>isEven = (x % 2 == 0)</code>, where <code>%</code> is the [[modulo]] operator * the use of simple arithmetic constants, e.g., in expressions such as <code>circumference = 2 * Math.PI * radius</code>,<ref name="MartinG25"/> or for calculating the [[discriminant]] of a [[quadratic equation]] as <code>d = b^2 β 4*a*c</code> * the use of powers of 10 to convert metric values (e.g. between grams and kilograms) or to calculate percentage and [[per mille]] values * exponents in expressions such as <code>(f(x) ** 2 + f(y) ** 2) ** 0.5</code> for <math>\sqrt{f(x)^2 + f(y)^2}</math> The constants 1 and 0 are sometimes used to represent the [[Boolean data type|Boolean]] values true and false in programming languages without a Boolean type, such as older versions of [[C (programming language)|C]]. Most modern programming languages provide a <code>boolean</code> or <code>bool</code> [[primitive type]] and so the use of 0 and 1 is ill-advised. This can be more confusing since 0 sometimes means programmatic success (when -1 means failure) and failure in other cases (when 1 means success). In C and C++, 0 represents the [[null pointer]]. As with Boolean values, the C standard library includes a macro definition <code>NULL</code> whose use is encouraged. Other languages provide a specific <code>null</code> or <code>nil</code> value and when this is the case no alternative should be used. The typed pointer constant <code>nullptr</code> has been introduced with C++11. == Format indicators {{anchor|Format indicator}} == === Origin {{anchor|Magic number origin}} === Format indicators were first used in early [[Version 7 Unix]] source code.{{citation needed|date=November 2019}} [[Unix]] was ported to one of the first [[Digital Equipment Corporation|DEC]] [[PDP-11]]/20s, which did not have [[memory protection]]. So early versions of Unix used the [[Position-independent code|relocatable memory reference]] model.<ref name="dmr">{{cite web |url=http://cm.bell-labs.com/cm/cs/who/dmr/odd.html |title=Odd Comments and Strange Doings in Unix |date=22 June 2002 |website=[[Bell Labs]] |url-status=dead |archive-url=https://web.archive.org/web/20061104034450/http://cm.bell-labs.com/cm/cs/who/dmr/odd.html |archive-date=2006-11-04}}</ref> Pre-[[Sixth Edition Unix]] versions read an executable file into [[magnetic-core memory|memory]] and jumped to the first low memory address of the program, [[relative address]] zero. With the development of [[Memory page|paged]] versions of Unix, a [[header (computing)|header]] was created to describe the [[executable|executable image]] components. Also, a [[branch instruction]] was inserted as the first word of the header to skip the header and start the program. In this way a program could be run in the older relocatable memory reference (regular) mode or in paged mode. As more executable formats were developed, new constants were added by incrementing the branch [[Offset (computer science)|offset]].<ref>Personal communication with Dennis M. Ritchie.</ref> In the [[Version 6 Unix|Sixth Edition]] [[Lions' Commentary on UNIX 6th Edition, with Source Code|source code]] of the Unix program loader, the exec() function read the executable ([[Binary numeral system|binary]]) image from the file system. The first 8 [[byte]]s of the file was a [[header (computing)|header]] containing the sizes of the program (text) and initialized (global) data areas. Also, the first 16-bit word of the header was compared to two [[constant (programming)|constant]]s to determine if the [[Executable|executable image]] contained [[Position-independent code|relocatable memory references]] (normal), the newly implemented [[Memory page|paged]] read-only executable image, or the separated instruction and data paged image.<ref name="V6sys1">{{cite web |url=https://minnie.tuhs.org/cgi-bin/utree.pl?file=V6/usr/sys/ken/sys1.c |title=The Unix Tree V6/usr/sys/ken/sys1.c |work=[[The Unix Heritage Society]] |archive-url=https://web.archive.org/web/20230326024616/https://minnie.tuhs.org/cgi-bin/utree.pl?file=V6/usr/sys/ken/sys1.c |archive-date=26 March 2023 |url-status=live }}</ref> There was no mention of the dual role of the header constant, but the high order byte of the constant was, in fact, the [[operation code]] for the PDP-11 branch instruction ([[octal]] 000407 or [[Hexadecimal|hex]] 0107). Adding seven to the program counter showed that if this constant was [[Executable|executed]], it would branch the Unix exec() service over the executable image eight byte header and start the program. Since the Sixth and Seventh Editions of Unix employed paging code, the dual role of the header constant was hidden. That is, the exec() service read the executable file header ([[Meta (prefix)|meta]]) data into a [[kernel space]] buffer, but read the executable image into [[user space]], thereby not using the constant's branching feature. Magic number creation was implemented in the Unix [[Linker (computing)|linker]] and [[Loader (computing)|loader]] and magic number branching was probably still used in the suite of [[Standalone program|stand-alone]] [[diagnostic program]]s that came with the Sixth and Seventh Editions. Thus, the header constant did provide an illusion and met the criteria for [[Magic (programming)|magic]]. In Version Seven Unix, the header constant was not tested directly, but assigned to a variable labeled '''ux_mag'''<ref name="V7sys1">{{cite web |url=https://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/sys/sys/sys1.c |title=The Unix Tree V7/usr/sys/sys/sys1.c |work=[[The Unix Heritage Society]] |archive-url=https://web.archive.org/web/20230326024632/https://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/sys/sys/sys1.c |archive-date=26 March 2023 |url-status=live }}</ref> and subsequently referred to as the '''magic number'''. Probably because of its uniqueness, the term '''magic number''' came to mean executable format type, then expanded to mean file system type, and expanded again to mean any type of file. === In files {{anchor|Magic numbers in files}} === <!-- Courtesy note per [[MOS:LINK2SECT]]: [[File format#Magic number]] links here. --> {{Main|File format#Magic number}} {{See also|List of file signatures}} Magic numbers are common in programs across many operating systems. Magic numbers implement [[strongly typed]] data and are a form of [[in-band signaling]] to the controlling program that reads the data type(s) at program run-time. Many files have such constants that identify the contained data. Detecting such constants in files is a simple and effective way of distinguishing between many [[file format]]s and can yield further run-time [[information]]. ;Examples * [[Compiler|Compiled]] [[Java class file]]s ([[Java bytecode|bytecode]]) and [[Mach (kernel)|Mach-O]] binaries start with hex <code>CAFEBABE</code>. When compressed with [[Pack200]] the bytes are changed to <code>CAFED00D</code>. * [[GIF]] image files have the [[ASCII]] code for "GIF89a" (<code>47</code> <code>49</code> <code>46</code> <code>38</code> <code>39</code> <code>61</code>) or "GIF87a" (<code>47</code> <code>49</code> <code>46</code> <code>38</code> <code>37</code> <code>61</code>) * [[JPEG]] image files begin with <code>FF</code> <code>D8</code> and end with <code>FF</code> <code>D9</code>. JPEG/[[JFIF]] files contain the [[Null-terminated string|null terminated string]] "JFIF" (<code>4A</code> <code>46</code> <code>49</code> <code>46</code> <code>00</code>). JPEG/[[Exif]] files contain the [[Null-terminated string|null terminated string]] "Exif" (<code>45</code> <code>78</code> <code>69</code> <code>66</code> <code>00</code>), followed by more [[Metadata (computing)|metadata]] about the file. * [[PNG]] image files begin with an 8-[[byte]] signature which identifies the file as a PNG file and allows detection of common file transfer problems: "\211PNG\r\n\032\n" (<code>89</code> <code>50</code> <code>4E</code> <code>47</code> <code>0D</code> <code>0A</code> <code>1A</code> <code>0A</code>). That signature contains various [[newline]] characters to permit detecting unwarranted automated newline conversions, such as transferring the file using [[File Transfer Protocol|FTP]] with the ''ASCII'' [[File Transfer Protocol#Protocol overview|transfer mode]] instead of the ''binary'' mode.<ref>{{cite web |url=http://www.libpng.org/pub/png/spec/1.0/PNG-Rationale.html#R.PNG-file-signature |title=PNG (Portable Network Graphics) Specification Version 1.0: 12.11. PNG file signature |date=1 October 1996 |work=MIT |archive-url=https://web.archive.org/web/20230326024630/http://www.libpng.org/pub/png/spec/1.0/PNG-Rationale.html#R.PNG-file-signature |archive-date=26 March 2023 |url-status=live }}</ref> * Standard [[MIDI]] audio files have the [[ASCII]] code for "MThd" ('''M'''IDI '''T'''rack '''h'''ea'''d'''er, <code>4D</code> <code>54</code> <code>68</code> <code>64</code>) followed by more metadata. * [[Unix]] or [[Linux]] scripts may start with a [[shebang (Unix)|shebang]] ("#!", <code>23</code> <code>21</code>) followed by the path to an [[interpreter directive|interpreter]], if the interpreter is likely to be different from the one from which the script was invoked. * [[Executable and Linkable Format|ELF]] executables start with the byte <code>7F</code> followed by "ELF" (<code>7F</code> <code>45</code> <code>4C</code> <code>46</code>). * [[PostScript]] files and programs start with "%!" (<code>25</code> <code>21</code>). * [[PDF]] files start with "%PDF" (hex <code>25</code> <code>50</code> <code>44</code> <code>46</code>). * [[DOS MZ executable]] files and the [[EXE#Other|EXE stub]] of the [[Microsoft Windows]] [[Portable Executable|PE]] (Portable Executable) files start with the characters "MZ" (<code>4D</code> <code>5A</code>), the initials of the designer of the file format, [[Mark Zbikowski]]. The definition allows the uncommon "ZM" (<code>5A</code> <code>4D</code>) as well for dosZMXP, a non-PE EXE.<ref name="doszmxp">{{cite web |url=https://blogs.msdn.microsoft.com/oldnewthing/20080324-00/?p=23033 |title=What's the difference between the COM and EXE extensions? |first=Raymond |last=Chen |date=24 March 2008 |work=The Old New Thing |url-status=dead |archive-url=https://web.archive.org/web/20190218083526/https://blogs.msdn.microsoft.com/oldnewthing/20080324-00/?p=23033 |archive-date=18 February 2019}}</ref> * The [[Berkeley Fast File System]] superblock format is identified as either <code>19</code> <code>54</code> <code>01</code> <code>19</code> or <code>01</code> <code>19</code> <code>54</code> depending on version; both represent the birthday of the author, [[Marshall Kirk McKusick]]. * The [[Master Boot Record]] of bootable storage devices on almost all [[IA-32]] [[IBM PC compatible]]s has a code of <code>55</code> <code>AA</code> as its last two bytes. * Executables for the [[Game Boy]] and [[Game Boy Advance]] handheld video game systems have a 48-byte or 156-byte magic number, respectively, at a fixed spot in the header. This magic number encodes a bitmap of the [[Nintendo]] logo. * [[Amiga]] software executable [[Amiga Hunk|Hunk]] files running on Amiga classic [[68000]] machines all started with the hexadecimal number $000003f3, nicknamed the "Magic Cookie." * In the Amiga, the only absolute address in the system is hex $0000 0004 (memory location 4), which contains the start location called SysBase, a pointer to exec.library, the so-called [[kernel (operating system)|kernel]] of Amiga. * [[Preferred Executable Format|PEF]] files, used by the [[classic Mac OS]] and [[BeOS]] for [[PowerPC]] executables, contain the [[ASCII]] code for "Joy!" (<code>4A</code> <code>6F</code> <code>79</code> <code>21</code>) as a prefix. * [[TIFF]] files begin with either "II" or "MM" followed by [[Answer to Life, the Universe, and Everything|42]] as a two-byte integer in little or big [[endianness|endian]] byte ordering. "II" is for Intel, which uses [[Endianness|little endian]] byte ordering, so the magic number is <code>49</code> <code>49</code> <code>2A</code> <code>00</code>. "MM" is for Motorola, which uses [[Endianness|big endian]] byte ordering, so the magic number is <code>4D</code> <code>4D</code> <code>00</code> <code>2A</code>. * [[Unicode]] text files encoded in [[UTF-16]] often start with the [[Byte Order Mark]] to detect [[endianness]] (<code>FE</code> <code>FF</code> for big endian and <code>FF</code> <code>FE</code> for little endian). And on [[Microsoft Windows]], [[UTF-8]] text files often start with the UTF-8 encoding of the same character, <code>EF</code> <code>BB</code> <code>BF</code>. * [[LLVM]] Bitcode files start with "BC" (<code>42</code> <code>43</code>). * [[Doom WAD|WAD]] files start with "IWAD" or "PWAD" (for ''[[Doom (1993 video game)|Doom]]''), "WAD2" (for ''[[Quake (video game)|Quake]]'') and "WAD3" (for ''[[Half-Life (video game)|Half-Life]]''). * Microsoft [[Compound File Binary Format]] (mostly known as one of the older formats of [[Microsoft Office]] documents) files start with <code>D0</code> <code>CF</code> <code>11</code> <code>E0</code>, which is visually suggestive of the word "DOCFILE0". * Headers in [[ZIP (file format)|ZIP]] files often show up in text editors as "PKβ₯β¦" (<code>50</code> <code>4B</code> <code>03</code> <code>04</code>), where "PK" are the initials of [[Phil Katz]], author of [[DOS]] compression utility [[PKZIP]]. * Headers in [[7z]] files begin with "7z" (full magic number: <code>37</code> <code>7A</code> <code>BC</code> <code>AF</code> <code>27</code> <code>1C</code>). ;Detection The Unix utility program <code>[[File (command)|file]]</code> can read and interpret magic numbers from files, and the file which is used to parse the information is called ''magic''. The Windows utility TrID has a similar purpose. === In protocols {{anchor|Magic numbers in protocols}} === ;Examples * The [[OSCAR protocol]], used in [[AOL Instant Messenger|AIM]]/[[ICQ]], prefixes requests with <code>2A</code>. * In the [[RFB protocol]] used by [[VNC]], a client starts its conversation with a server by sending "RFB" (<code>52</code> <code>46</code> <code>42</code>, for "Remote Frame Buffer") followed by the client's protocol version number. * In the [[Server Message Block|SMB]] protocol used by Microsoft Windows, each SMB request or server reply begins with '<code>FF</code> <code>53</code> <code>4D</code> <code>42</code>', or <code>"\xFFSMB"</code> at the start of the SMB request. * In the [[MSRPC]] protocol used by Microsoft Windows, each TCP-based request begins with <code>05</code> at the start of the request (representing Microsoft DCE/RPC Version 5), followed immediately by a <code>00</code> or <code>01</code> for the minor version. In UDP-based MSRPC requests the first byte is always <code>04</code>. * In [[Component Object Model|COM]] and [[Distributed Component Object Model|DCOM]] marshalled interfaces, called [[OBJREF]]s, always start with the byte sequence "MEOW" (<code>4D</code> <code>45</code> <code>4F</code> <code>57</code>). Debugging extensions (used for DCOM channel hooking) are prefaced with the byte sequence "MARB" (<code>4D</code> <code>41</code> <code>52</code> <code>42</code>). * Unencrypted [[BitTorrent tracker]] requests begin with a single byte containing the value <code>19</code> representing the header length, followed immediately by the phrase "BitTorrent protocol" at byte position 1. * [[eDonkey2000]]/[[eMule]] traffic begins with a single byte representing the client version. Currently <code>E3</code> represents an eDonkey client, <code>C5</code> represents eMule, and <code>D4</code> represents compressed eMule. * The first 4 bytes of a block in the [[Bitcoin]] Blockchain contains a magic number which serves as the network identifier. The value is a constant <code>0xD9B4BEF9</code>, which indicates the main network, while the constant <code> 0xDAB5BFFA</code> indicates the testnet. * [[Secure Sockets Layer|SSL]] transactions always begin with a "client hello" message. The record encapsulation scheme used to prefix all SSL packets consists of two- and three- byte header forms. Typically an SSL version 2 client hello message is prefixed with an <code>80</code> and an SSLv3 server response to a client hello begins with <code>16</code> (though this may vary). * [[DHCP]] packets use a "magic cookie" value of '<code>0x63</code> <code>0x82</code> <code>0x53</code> <code>0x63</code>' at the start of the options section of the packet. This value is included in all DHCP packet types. * [[HTTP/2]] connections are opened with the preface '<code>0x505249202a20485454502f322e300d0a0d0a534d0d0a0d0a</code>', or "<code>PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n</code>". The preface is designed to avoid the processing of frames by servers and intermediaries which support earlier versions of HTTP but not 2.0. * The [[WebSocket#Opening handshake|WebSocket opening handshake]] uses the string <code>''258EAFA5-E914-47DA-95CA-C5AB0DC85B11''</code>. === In interfaces {{anchor|Magic numbers in interfaces}} === Magic numbers are common in [[API function]]s and [[interface (computing)|interface]]s across many [[operating system]]s, including [[DOS]], [[Windows]] and [[NetWare]]: ;Examples * [[IBM PC]]-compatible [[BIOS]]es use magic values <code>0000</code> and <code>1234</code> to decide if the system should count up memory or not on reboot, thereby performing a cold or a warm boot. Theses values are also used by [[EMM386]] memory managers intercepting boot requests.<ref name="Paul_2002_MAGIC"/> BIOSes also use magic values <code>55 AA</code> to determine if a disk is bootable.<ref>{{Cite web |url=http://neosmart.net/wiki/mbr-boot-process/ |title=The BIOS/MBR Boot Process |date=2015-01-25 |website=NeoSmart Knowledgebase |language=en-US |access-date=2019-02-03 |archive-url=https://web.archive.org/web/20230326024702/https://neosmart.net/wiki/mbr-boot-process/ |archive-date=26 March 2023 |url-status=live }}</ref> * The [[MS-DOS]] disk cache [[SMARTDRV]] (codenamed "Bambi") uses magic values BABE and EBAB in API functions.<ref name="Paul_2002_MAGIC"/> * Many [[DR-DOS]], [[Novell DOS]] and [[OpenDOS]] drivers developed in the former ''European Development Centre'' in the UK use the value 0EDC as magic token when invoking or providing additional functionality sitting on top of the (emulated) standard DOS functions, NWCACHE being one example.<ref name="Paul_2002_MAGIC"/> === Other uses {{anchor|Magic numbers in other uses}} === ;Examples * The default [[MAC address]] on Texas Instruments [[System on a chip|SOCs]] is DE:AD:BE:EF:00:00.<ref>{{cite web |url=http://e2e.ti.com/support/wireless_connectivity/f/307/p/131036/589272.aspx |title=TI E2E Community: Does anyone know if the following configurations can be done with MCP CLI Tool? |date=27 August 2011 |work=Texas Instruments |archive-url=https://web.archive.org/web/20221007161243/https://e2e.ti.com/support/processors-group/processors/f/processors-forum/589272/ccs-tms320c5545-c5545-uart_test-to-run-without-msp430 |archive-date=7 October 2022 |url-status=live }}</ref> == Data type limits == This is a list of limits of data storage types:<ref>{{Cite web |url=https://learn.microsoft.com/en-us/previous-versions/software-testing/ee621251(v=msdn.10) |title=Magic Numbers: Integers |last=Poley |first=Josh |date=30 September 2009 |website=Learn |publisher=[[Microsoft]] |archive-url=https://web.archive.org/web/20230328134018/https://learn.microsoft.com/en-us/previous-versions/software-testing/ee621251%28v=msdn.10%29 |archive-date=28 March 2023 |url-status=live }}</ref> {| class="wikitable" !Decimal !Hex !Description |- |[[18,446,744,073,709,551,615]] |FFFF{{thin space}}FFFF{{thin space}}FFFF{{thin space}}FFFF |The maximum unsigned 64 bit value (2<sup>64</sup> β 1) |- |[[9,223,372,036,854,775,807]] |7FFF{{thin space}}FFFF{{thin space}}FFFF{{thin space}}FFFF |The maximum signed 64 bit value (2<sup>63</sup> β 1) |- |[[9,007,199,254,740,992]] |0020{{thin space}}0000{{thin space}}0000{{thin space}}0000 |The largest consecutive integer in [[Double-precision floating-point format|IEEE 754 double precision]] (2<sup>53</sup>) |- |[[4,294,967,295]] |FFFF{{thin space}}FFFF |The maximum unsigned 32 bit value (2<sup>32</sup> β 1) |- |[[2,147,483,647]] |7FFF{{thin space}}FFFF |The maximum signed 32 bit value (2<sup>31</sup> β 1) |- |[[16,777,216]] |0100{{thin space}}0000 |The largest consecutive integer in [[Single-precision floating-point format|IEEE 754 single precision]] (2<sup>24</sup>) |- |[[65,535]] |FFFF |The maximum unsigned 16 bit value (2<sup>16</sup> β 1) |- |32,767 |7FFF |The maximum signed 16 bit value (2<sup>15</sup> β 1) |- |[[255 (number)|255]] |FF |The maximum unsigned 8 bit value (2<sup>8</sup> β 1) |- |127 |7F |The maximum signed 8 bit value (2<sup>7</sup> β 1) |- | β128 |80 |Minimum signed 8 bit value |- | β32,768 |8000 |Minimum signed 16 bit value |- | β2,147,483,648 |8000{{thin space}}0000 |Minimum signed 32 bit value |- | β9,223,372,036,854,775,808 |8000{{thin space}}0000{{thin space}}0000{{thin space}}0000 |Minimum signed 64 bit value |} == GUIDs {{anchor|Magic GUIDs}} == It is possible to create or alter [[globally unique identifier]]s (GUIDs) so that they are memorable, but this is highly discouraged as it compromises their strength as near-unique identifiers.<ref>{{cite web |url=http://www.developerfusion.co.uk/show/1713/4/ |title=Message Management: Guaranteeing uniqueness |first=Joseph M. |last=Newcomer |date=13 October 2001 |work=Developer Fusion |access-date=2007-11-16 |archive-url=https://web.archive.org/web/20050421023819/https://www.developerfusion.com/show/1713/4/ |archive-date=21 April 2005 |url-status=dead }}</ref><ref>{{cite web |url=https://learn.microsoft.com/en-us/archive/blogs/larryosterman/uuids-are-only-unique-if-you-generate-them |title=UUIDs are only unique if you generate them... |first=Larry |last=Osterman |date=21 July 2005 |work=Larry Osterman's WebLog - Confessions of an Old Fogey |publisher=MSDN |access-date=2007-11-16 |archive-url=https://web.archive.org/web/20230328134453/https://learn.microsoft.com/en-us/archive/blogs/larryosterman/uuids-are-only-unique-if-you-generate-them |archive-date=28 March 2023 |url-status=live }}</ref> The specifications for generating GUIDs and UUIDs are quite complex, which is what leads to them being virtually unique, if properly implemented.<ref>{{cite web | url=https://datatracker.ietf.org/doc/html/rfc9562 | title=RFC 9562 - Universally Unique IDentifiers (UUIDs) | date=May 2024 | website=ietf.org | access-date=9 August 2024 }}</ref> Microsoft Windows product ID numbers for [[Microsoft Office]] products sometimes end with <code>0000-0000-0000000FF1CE</code> ("OFFICE"), such as {<code>90160000-008C-0000-0000-0000000FF1CE</code>}, the product ID for the "Office 16 Click-to-Run Extensibility Component". Java uses several GUIDs starting with <code>CAFEEFAC</code>.<ref>{{cite web |url=https://www.oracle.com/java/technologies/javase/family-clsid.html |title=Deploying Java Applets With Family JRE Versions in Java Plug-in for Internet Explorer |publisher=[[Oracle Corporation|Oracle]] |access-date=28 March 2023 |archive-url=https://web.archive.org/web/20221130180350/https://www.oracle.com/java/technologies/javase/family-clsid.html |archive-date=30 November 2022 |url-status=live }}</ref> In the [[GUID Partition Table]] of the GPT partitioning scheme, [[BIOS Boot partition]]s use the special GUID {<code>21686148-6449-6E6F-744E-656564454649</code>}<ref>{{cite web |url=https://www.gnu.org/software/grub/manual/html_node/BIOS-installation.html |title=GNU GRUB Installation, Section 3.4: BIOS installation |access-date=2014-06-26 |website=Gnu.org |archive-url=https://web.archive.org/web/20230315232257/https://www.gnu.org/software/grub/manual/grub/html_node/BIOS-installation.html |archive-date=15 March 2023 |url-status=live }}</ref> which does not follow the GUID definition; instead, it is formed by using the [[ASCII]] codes for the string "<code>Hah!IdontNeedEFI</code>" partially in [[little endian]] order.<ref>{{cite web |url=https://www.howtogeek.com/201059/magic-numbers-the-secret-codes-that-programmers-hide-in-your-pc/ |title=Magic Numbers: The Secret Codes that Programmers Hide in Your PC |first=Lowell |last=Heddings |date=3 November 2014 |work=How-To Geek |access-date=3 October 2017 |archive-url=https://web.archive.org/web/20230326024750/https://www.howtogeek.com/201059/magic-numbers-the-secret-codes-that-programmers-hide-in-your-pc/ |archive-date=26 March 2023 |url-status=live }}</ref> == Debug values {{anchor|Magic debug values}} == '''Magic debug values''' are specific values written to [[Random-access memory|memory]] during [[memory allocation|allocation]] or deallocation, so that it will later be possible to tell whether or not they have become corrupted, and to make it obvious when values taken from uninitialized memory are being used. Memory is usually viewed in hexadecimal, so memorable repeating or [[hexspeak]] values are common. Numerically odd values may be preferred so that processors without byte addressing will fault when attempting to use them as pointers (which must fall at even addresses). Values should be chosen that are away from likely addresses (the program code, static data, heap data, or the stack). Similarly, they may be chosen so that they are not valid codes in the instruction set for the given architecture. Since it is very unlikely, although possible, that a 32-bit integer would take this specific value, the appearance of such a number in a [[debugger]] or [[memory dump]] most likely indicates an error such as a buffer overflow or an [[uninitialized variable]]. Famous and common examples include: <!-- Please understand the above description before adding things! This is not the place for other kinds of magic numbers like header signatures or error codes. --> {| class="wikitable" |- ! style="background:#D0E0FF"| Code ! style="background:#D0E0FF"| Description |- | <code>00008123</code> || Used in MS Visual C++. Deleted pointers are set to this value, so they throw an exception, when they are used after; it is a more recognizable alias for the zero address. It is activated with the Security Development Lifecycle (/sdl) option.<ref>{{cite web |last1=Cavit |first1=Doug |date=24 April 2012 |title=Guarding against re-use of stale object references |url=https://cloudblogs.microsoft.com/microsoftsecure/2012/04/24/guarding-against-re-use-of-stale-object-references/ |website=Microsoft Secure |access-date=26 July 2018 |archive-url=https://web.archive.org/web/20180726103946/https://cloudblogs.microsoft.com/microsoftsecure/2012/04/24/guarding-against-re-use-of-stale-object-references/ |archive-date=26 July 2018 |url-status=dead }}</ref> |- | <code>..FACADE</code> || ''"Facade"'', Used by a number of [[real-time operating system|RTOS]]es |- | <code>1BADB002</code> || ''"1 bad boot"'', [[Multiboot Specification|Multiboot]] header magic number<ref>{{cite web |url=http://ftp.lyx.org/pub/mach/mach4/multiboot/multiboot-archive |title=Comments on the 'MultiBoot Standard' proposal |first=Erich Stefan |last=Boleyn |date=4 April 1995 |website=Uruk.org |archive-url=https://web.archive.org/web/20230326024756/http://ftp.lyx.org/pub/mach/mach4/multiboot/multiboot-archive |archive-date=26 March 2023 |url-status=live }}</ref> |- | <code>8BADF00D</code> || ''"Ate bad food"'', Indicates that an [[Apple Inc.|Apple]] [[iOS]] application has been terminated because a watchdog timeout occurred.<ref name="developer.apple.com">{{Cite web |url=https://developer.apple.com/library/archive/technotes/tn2151/_index.html |title=Technical Note TN2151: Understanding and Analyzing Application Crash Reports |date=29 January 2009 |website=Apple Developer Documentation |archive-url=https://web.archive.org/web/20181213234116/https://developer.apple.com/library/archive/technotes/tn2151/_index.html |archive-date=13 December 2018 |url-status=dead }}</ref> |- | <code>A5A5A5A5</code> || Used in embedded development because the alternating bit pattern (1010 0101) creates an easily recognized pattern on [[oscilloscope]]s and [[logic analyzer]]s. |- | <code>A5</code> || Used in [[FreeBSD]]'s PHK [[malloc|malloc(3)]] for debugging when /etc/malloc.conf is symlinked to "-J" to initialize all newly allocated memory as this value is not a NULL pointer or ASCII NUL character. |- | <code>ABABABAB</code> || Used by [[Microsoft]]'s debug HeapAlloc() to mark "no man's land" [[guard byte]]s after allocated heap memory.<ref name="Win32CRTDebugHeapInternals">{{cite web |url=http://www.nobugs.org/developer/win32/debug_crt_heap.html |title=Win32 Debug CRT Heap Internals |first=Andrew |last=Birkett |work=Nobugs.org}}</ref> |- | <code>ABADBABE</code> || ''"A bad babe"'', Used by [[Apple Inc.|Apple]] as the "Boot Zero Block" magic number |- | <code>ABBABABE</code> || ''"[[ABBA]] babe"'', used by ''[[Driver: Parallel Lines]]'' memory heap. |- | <code>ABADCAFE</code> || ''"A bad cafe"'', Used to initialize all unallocated memory (Mungwall, [[AmigaOS]]) |- | <code>B16B00B5</code> || ''"Big Boobs"'', Formerly required by [[Microsoft]]'s [[Hyper-V]] hypervisor to be used by Linux guests as the upper half of their "guest id"<ref>{{Cite web |url=https://www.networkworld.com/article/2222804/microsoft-code-contains-the-phrase--big-boobs------yes--really.html |title=Microsoft code contains the phrase 'big boobs' ... Yes, really |first=Paul |last=McNamara |date=19 July 2012 |website=Network World}}</ref> |- | <code>BAADF00D</code> || ''"Bad food"'', Used by [[Microsoft]]'s debug HeapAlloc() to mark uninitialized allocated heap memory<ref name="Win32CRTDebugHeapInternals"/> |- | <code>BAAAAAAD</code> || ''"Baaaaaad"'', Indicates that the [[Apple Inc.|Apple]] [[iOS]] log is a stackshot of the entire system, not a crash report<ref name="developer.apple.com"/> |- | <code>BAD22222</code> || ''"Bad too repeatedly"'', Indicates that an [[Apple Inc.|Apple]] [[iOS]] VoIP application has been terminated because it resumed too frequently<ref name="developer.apple.com"/> |- | <code>BADBADBADBAD</code> || ''"Bad bad bad bad"'', [[Burroughs large systems]] "uninitialized" memory (48-bit words) |- | <code>BADC0FFEE0DDF00D</code> || ''"Bad coffee odd food"'', Used on [[IBM]] [[RS/6000]] 64-bit systems to indicate uninitialized CPU registers |- | <code>BADDCAFE</code> || ''"Bad cafe"'', On [[Sun Microsystems]]' [[Solaris (operating system)|Solaris]], marks uninitialized kernel memory (KMEM_UNINITIALIZED_PATTERN) |- | <code>BBADBEEF</code> || ''"Bad beef"'', Used in [[WebKit]], for particularly unrecoverable errors<ref>{{Citation |title=WebKit |date=2023-01-06 |url=https://github.com/WebKit/WebKit/blob/226b2f3cb9fa175dbf0a8025d882ac3b168b7547/Source/WTF/wtf/Assertions.cpp |publisher=The WebKit Open Source Project |access-date=2023-01-06}}</ref> |- | <code>BEBEBEBE</code> || Used by [[AddressSanitizer]] to fill allocated but not initialized memory<ref>{{cite web |url=https://github.com/google/sanitizers/wiki/AddressSanitizer#faq |title=AddressSanitizer - FAQ |website=[[GitHub]] |access-date=2022-05-18}}</ref> |- | <code>BEEFCACE</code> || ''"Beef cake"'', Used by [[Microsoft .NET]] as a magic number in resource files |- | <code>C00010FF</code> || ''"Cool off"'', Indicates [[Apple Inc.|Apple]] [[iOS]] app was killed by the operating system in response to a thermal event<ref name="developer.apple.com"/> |- | <code>CAFEBABE</code> || ''"Cafe babe"'', Used by [[Java (programming language)|Java]] for class files |- | <code>CAFED00D</code> || ''"Cafe dude"'', Used by [[Java (programming language)|Java]] for their [[pack200]] compression |- | <code>CAFEFEED</code> || ''"Cafe feed"'', Used by [[Sun Microsystems]]' [[Solaris (operating system)|Solaris]] debugging kernel to mark kmemfree() memory |- | <code>CCCCCCCC</code> || Used by [[Microsoft]]'s C++ debugging runtime library and many DOS environments to mark uninitialized [[stack-based memory allocation|stack]] memory. <code>CC</code> is the opcode of the [[INT 3]] debug breakpoint interrupt on x86 processors.<ref>{{cite web | url=https://pdos.csail.mit.edu/6.828/2008/readings/i386/INT.htm | title=INTEL 80386 PROGRAMMER'S REFERENCE MANUAL | publisher=[[MIT]]}}</ref> |- | <code>CDCDCDCD</code> || Used by [[Microsoft]]'s C/C++ debug malloc() function to mark uninitialized heap memory, usually returned from HeapAlloc()<ref name="Win32CRTDebugHeapInternals" /> |- | <code>0D15EA5E</code> || ''"Zero Disease"'', Used as a flag to indicate regular boot on the [[GameCube]] and [[Wii]] consoles |- | <code>DDDDDDDD</code> || Used by MicroQuill's SmartHeap and Microsoft's C/C++ debug free() function to mark freed heap memory<ref name="Win32CRTDebugHeapInternals" /> |- | <code>DEAD10CC</code> || ''"Dead lock"'', Indicates that an [[Apple Inc.|Apple]] [[iOS]] application has been terminated because it held on to a system resource while running in the background<ref name="developer.apple.com"/> |- | <code>DEADBABE</code> || ''"Dead babe"'', Used at the start of [[Silicon Graphics]]' [[IRIX]] arena files |- id="DEADBEEF" | <code>DEADBEEF</code> || ''"Dead beef"'', Famously used on [[IBM]] systems such as the [[RS/6000]], also used in the [[classic Mac OS]] [[operating system]]s, [[OPENSTEP Enterprise]], and the [[Commodore International|Commodore]] [[Amiga]]. On [[Sun Microsystems]]' [[Solaris (operating system)|Solaris]], marks freed kernel memory (KMEM_FREE_PATTERN) |- | <code>DEADCAFE</code> || ''"Dead cafe"'', Used by [[Microsoft .NET]] as an error number in [[Dynamic-link library|DLL]]s |- | <code>DEADC0DE</code> || ''"Dead code"'', Used as a marker in [[OpenWRT]] firmware to signify the beginning of the to-be created jffs2 file system at the end of the static firmware |- | <code>DEADFA11</code> || ''"Dead fail"'', Indicates that an [[Apple Inc.|Apple]] [[iOS]] application has been force quit by the user<ref name="developer.apple.com"/> |- | <code>DEADF00D</code> || ''"Dead food"'', Used by Mungwall on the [[Commodore International|Commodore]] [[Amiga]] to mark allocated but uninitialized memory<ref>{{cite web |url=http://cataclysm.cx/random/amiga/reference/AmigaMail_Vol2_guide/node0053.html |title=Amiga Mail Vol.2 Guide |first=Carolyn |last=Scheppner |work=Cataclysm.cx |access-date=2010-08-20 |url-status=dead |archive-url=https://web.archive.org/web/20110718163417/http://cataclysm.cx/random/amiga/reference/AmigaMail_Vol2_guide/node0053.html |archive-date=2011-07-18}}</ref> |- | <code>DEFEC8ED</code> || ''"Defecated"'', Used for [[OpenSolaris]] [[core dump]]s |- | <code>DEADDEAD</code> || ''"Dead Dead"'' indicates that the user deliberately initiated a crash dump from either the kernel debugger or the keyboard under Microsoft Windows.<ref>{{Cite web |url=https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/bug-check-0xdeaddead--manually-initiated-crash1 |title=Bug Check 0xDEADDEAD MANUALLY_INITIATED_CRASH1 |website=Microsoft Documentation|date=19 June 2023 }}</ref> |- |<code>D00D2BAD</code> |''"Dude, Too Bad",'' Used by Safari crashes on macOS Big Sur.<ref>{{Cite web|title=Safari Version 14.0.1 Unexpectedly Quits|url=https://discussions.apple.com/thread/252054569}}</ref> |- |<code>D00DF33D</code> |''"Dude feed",'' Used by the [[devicetree]] to mark the start of headers.<ref>{{Cite web|title=Device Tree Specification|url=https://www.devicetree.org/specifications/}}</ref> |- | <code>EBEBEBEB</code> || From MicroQuill's SmartHeap |- | <code>FADEDEAD</code> || ''"Fade dead"'', Comes at the end to identify every [[AppleScript]] script |- | <code>FDFDFDFD</code> || Used by [[Microsoft]]'s C/C++ debug malloc() function to mark "no man's land" [[guard byte]]s before and after allocated heap memory,<ref name="Win32CRTDebugHeapInternals" /> and some debug Secure [[C standard library|C-Runtime]] functions implemented by Microsoft (e.g. strncat_s) <ref>{{cite web |title=strncat_s, _strncat_s_l, wcsncat_s, _wcsncat_s_l, _mbsncat_s, _mbsncat_s_l |url=https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/strncat-s-strncat-s-l-wcsncat-s-wcsncat-s-l-mbsncat-s-mbsncat-s-l?view=vs-2017 |website=Microsoft Documentation |access-date=16 January 2019 |language=en-us}}</ref> |- | <code>FEE1DEAD</code> || ''"Feel dead"'', Used by [[Linux]] reboot() syscall |- | <code>FEEDFACE</code> || ''"Feed face"'', Seen in PowerPC [[Mach-O]] binaries on [[Apple Inc.]]'s Mac OSX platform. On [[Sun Microsystems]]' [[Solaris (operating system)|Solaris]], marks the red zone (KMEM_REDZONE_PATTERN) Used by [[VLC player]] and some [[IP camera]]s in [[Real-time Transport Protocol|RTP]]/[[RTCP]] protocol, VLC player sends four bytes in the order of the [[endianness]] of the system. Some IP cameras expect the player to send this magic number and do not start the stream if it is not received. |- | <code>FEEEFEEE</code> || ''"Fee fee"'', Used by [[Microsoft]]'s debug HeapFree() to mark freed heap memory. Some nearby internal bookkeeping values may have the high word set to FEEE as well.<ref name="Win32CRTDebugHeapInternals" /> |} Most of these are 32 [[bit]]s long{{snd}}the [[word size]] of most 32-bit architecture computers. The prevalence of these values in Microsoft technology is no coincidence; they are discussed in detail in [[Steve Maguire]]'s book ''Writing Solid Code'' from [[Microsoft Press]]. He gives a variety of criteria for these values, such as: * They should not be useful; that is, most algorithms that operate on them should be expected to do something unusual. Numbers like zero don't fit this criterion. * They should be easily recognized by the programmer as invalid values in the debugger. * On machines that don't have [[byte alignment]], they should be [[odd number]]s, so that dereferencing them as addresses causes an exception. * They should cause an exception, or perhaps even a debugger break, if executed as code. Since they were often used to mark areas of memory that were essentially empty, some of these terms came to be used in phrases meaning "gone, aborted, flushed from memory"; e.g. "Your program is DEADBEEF".{{citation needed|date=June 2020}} == See also == * [[Magic string]] * {{slink|File format|Magic number}} * [[List of file signatures]] * [[FourCC]] * [[Hard coding]] * [[Magic (programming)]] * [[NaN]] (Not a Number) * [[Enumerated type]] * [[Hexspeak]], for another list of magic values * [[Nothing up my sleeve number]] about magic constants in [[cryptography|cryptographic]] algorithms * [[Time formatting and storage bugs]], for problems that can be caused by magics * [[Sentinel value]] (aka flag value, trip value, rogue value, signal value, dummy data) * [[Canary value]], special value to detect buffer overflows * [[XYZZY (magic word)]] * [[Fast inverse square root]], an algorithm that uses the constant 0x5F3759DF == References == {{Reflist|refs= <ref name="Paul_2002_MAGIC">{{cite web |title=[fd-dev] Ctrl+Alt+Del |author-first=Matthias R. |author-last=Paul |date=2002-04-03 |work=freedos-dev |url=https://marc.info/?l=freedos-dev&m=101783474625117 |access-date=2017-09-09 |url-status=live |archive-url=https://archive.today/20170909084942/https://marc.info/?l=freedos-dev&m=101783474625117 |archive-date=2017-09-09}} (NB. Mentions a number of magic values used by [[IBM PC]]-compatible [[BIOS]]es (0000h, 1234h), [[DOS]] memory managers like [[EMM386]] (1234h) and disk caches like [[SMARTDRV]] (EBABh, BABEh) and NWCACHE (0EDCh, EBABh, 6756h).)</ref> <ref name="Paul_2002_SYMBOLS">{{cite web |title=[fd-dev] CuteMouse 2.0 alpha 1 |author-first=Matthias R. |author-last=Paul |work=freedos-dev |date=2002-04-09 |url=https://marc.info/?l=freedos-dev&m=101832534205646&w=2 |access-date=2022-08-04 |url-status=live |archive-url=https://web.archive.org/web/20220407144249/https://marc.info/?l=freedos-dev&m=101832534205646&w=2 |archive-date=2022-04-07}}</ref> }} {{Computer files}} [[Category:Anti-patterns]] [[Category:Debugging]] [[Category:Computer programming folklore]] [[Category:Software engineering folklore]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Anchor
(
edit
)
Template:Citation
(
edit
)
Template:Citation needed
(
edit
)
Template:Cite book
(
edit
)
Template:Cite web
(
edit
)
Template:Code
(
edit
)
Template:Computer files
(
edit
)
Template:Crossref
(
edit
)
Template:Main
(
edit
)
Template:More citations needed section
(
edit
)
Template:Reflist
(
edit
)
Template:See also
(
edit
)
Template:Short description
(
edit
)
Template:Slink
(
edit
)
Template:Snd
(
edit
)
Template:Thin space
(
edit
)
Template:Use dmy dates
(
edit
)