[{"data":1,"prerenderedAt":822},["ShallowReactive",2],{"guide-hexadecimal-guide":3},{"id":4,"title":5,"body":6,"date":813,"description":814,"extension":815,"meta":816,"navigation":416,"path":817,"readingTime":818,"seo":819,"stem":820,"__hash__":821},"guides\u002Fguides\u002Fhexadecimal-guide.md","Hexadecimal Guide: Why Developers Use Base-16 Every Day",{"type":7,"value":8,"toc":789},"minimark",[9,14,18,126,129,140,159,163,166,172,187,190,194,199,202,260,263,287,291,294,305,311,315,326,332,339,343,346,444,448,452,455,567,573,577,580,586,589,617,621,624,630,634,638,653,657,670,674,686,690,700,720,724,749,753,767,771,785],[10,11,13],"h2",{"id":12},"what-is-hexadecimal","What Is Hexadecimal?",[15,16,17],"p",{},"Hexadecimal (hex) is a base-16 number system. It uses sixteen distinct symbols: the digits 0 through 9 and the letters A through F. The letters represent decimal values 10 through 15.",[19,20,21,79],"table",{},[22,23,24],"thead",{},[25,26,27,31,34,37,40,43,46,49,52,55,58,61,64,67,70,73,76],"tr",{},[28,29,30],"th",{},"Hex Digit",[28,32,33],{},"0",[28,35,36],{},"1",[28,38,39],{},"2",[28,41,42],{},"3",[28,44,45],{},"4",[28,47,48],{},"5",[28,50,51],{},"6",[28,53,54],{},"7",[28,56,57],{},"8",[28,59,60],{},"9",[28,62,63],{},"A",[28,65,66],{},"B",[28,68,69],{},"C",[28,71,72],{},"D",[28,74,75],{},"E",[28,77,78],{},"F",[80,81,82],"tbody",{},[25,83,84,88,90,92,94,96,98,100,102,104,106,108,111,114,117,120,123],{},[85,86,87],"td",{},"Decimal",[85,89,33],{},[85,91,36],{},[85,93,39],{},[85,95,42],{},[85,97,45],{},[85,99,48],{},[85,101,51],{},[85,103,54],{},[85,105,57],{},[85,107,60],{},[85,109,110],{},"10",[85,112,113],{},"11",[85,115,116],{},"12",[85,118,119],{},"13",[85,121,122],{},"14",[85,124,125],{},"15",[15,127,128],{},"Each position in a hex number represents a power of 16. For example:",[130,131,136],"pre",{"className":132,"code":134,"language":135},[133],"language-text","2A3 = 2 × 16² + 10 × 16¹ + 3 × 16⁰\n    = 512 + 160 + 3\n    = 675 (decimal)\n","text",[137,138,134],"code",{"__ignoreMap":139},"",[15,141,142,143,146,147,150,151,154,155,158],{},"Programmers write hex values with a ",[137,144,145],{},"0x"," prefix in most languages (",[137,148,149],{},"0xFF",") or a ",[137,152,153],{},"#"," prefix in CSS (",[137,156,157],{},"#FF5733","). These prefixes tell the reader and the compiler that the number is base-16, not base-10.",[10,160,162],{"id":161},"why-hexadecimal","Why Hexadecimal?",[15,164,165],{},"Hex exists for one reason: it makes binary readable. One hex digit maps exactly to four binary digits (bits). This means a byte — 8 bits — always becomes exactly two hex digits.",[130,167,170],{"className":168,"code":169,"language":135},[133],"Binary: 1111 1010\nHex:      F    A\nResult: 0xFA\n",[137,171,169],{"__ignoreMap":139},[15,173,174,175,178,179,182,183,186],{},"Compare that to the decimal equivalent: 250 tells you nothing about which bits are set. The hex value ",[137,176,177],{},"FA"," shows you immediately that the high nibble is ",[137,180,181],{},"1111"," and the low nibble is ",[137,184,185],{},"1010",".",[15,188,189],{},"This one-to-four mapping is why hex won out over octal (base-8) in modern computing. Octal groups bits in threes, which doesn't align cleanly with 8-bit, 16-bit, or 32-bit boundaries. Hex aligns perfectly with all of them.",[10,191,193],{"id":192},"hex-in-everyday-programming","Hex in Everyday Programming",[195,196,198],"h3",{"id":197},"css-color-values","CSS Color Values",[15,200,201],{},"Every web developer encounters hex daily through CSS colors. A six-digit hex color specifies red, green, and blue channels, each ranging from 00 to FF (0 to 255).",[130,203,207],{"className":204,"code":205,"language":206,"meta":139,"style":139},"language-css shiki shiki-themes github-light github-dark",".hot-pink  { color: #FF69B4; }  \u002F* R=255, G=105, B=180 *\u002F\n.deep-blue { color: #003366; }  \u002F* R=0,   G=51,  B=102  *\u002F\n","css",[137,208,209,239],{"__ignoreMap":139},[210,211,214,218,222,226,229,232,235],"span",{"class":212,"line":213},"line",1,[210,215,217],{"class":216},"sScJk",".hot-pink",[210,219,221],{"class":220},"sVt8B","  { ",[210,223,225],{"class":224},"sj4cs","color",[210,227,228],{"class":220},": ",[210,230,231],{"class":224},"#FF69B4",[210,233,234],{"class":220},"; }  ",[210,236,238],{"class":237},"sJ8bj","\u002F* R=255, G=105, B=180 *\u002F\n",[210,240,242,245,248,250,252,255,257],{"class":212,"line":241},2,[210,243,244],{"class":216},".deep-blue",[210,246,247],{"class":220}," { ",[210,249,225],{"class":224},[210,251,228],{"class":220},[210,253,254],{"class":224},"#003366",[210,256,234],{"class":220},[210,258,259],{"class":237},"\u002F* R=0,   G=51,  B=102  *\u002F\n",[15,261,262],{},"Modern CSS also supports 8-digit hex with an alpha channel:",[130,264,266],{"className":204,"code":265,"language":206,"meta":139,"style":139},".semi-transparent { color: #FF573380; }  \u002F* 50% opacity *\u002F\n",[137,267,268],{"__ignoreMap":139},[210,269,270,273,275,277,279,282,284],{"class":212,"line":213},[210,271,272],{"class":216},".semi-transparent",[210,274,247],{"class":220},[210,276,225],{"class":224},[210,278,228],{"class":220},[210,280,281],{"class":224},"#FF573380",[210,283,234],{"class":220},[210,285,286],{"class":237},"\u002F* 50% opacity *\u002F\n",[195,288,290],{"id":289},"memory-addresses-and-debugging","Memory Addresses and Debugging",[15,292,293],{},"When you print a pointer in C, C++, or Rust, the output is hex. Debuggers display memory addresses in hex. Profilers annotate stack traces with hex offsets.",[130,295,299],{"className":296,"code":297,"language":298,"meta":139,"style":139},"language-c shiki shiki-themes github-light github-dark","printf(\"%p\", &variable);  \u002F\u002F Output: 0x7ffd4a3b2c10\n","c",[137,300,301],{"__ignoreMap":139},[210,302,303],{"class":212,"line":213},[210,304,297],{},[15,306,307,308,310],{},"Hex makes these addresses scannable. You can quickly spot alignment (addresses ending in ",[137,309,33],{}," are 16-byte aligned) and page boundaries (addresses where multiple high bits change).",[195,312,314],{"id":313},"byte-representation","Byte Representation",[15,316,317,318,321,322,325],{},"When you inspect raw data — network packets, file headers, binary protocols — you see hex dumps. Tools like ",[137,319,320],{},"xxd",", ",[137,323,324],{},"hexdump",", and Wireshark display bytes as hex pairs.",[130,327,330],{"className":328,"code":329,"language":135},[133],"00000000: 7f45 4c46 0201 0100 0000 0000 0000 0000  .ELF............\n00000010: 0200 3e00 0100 0000 0040 0000 0000 0000  ..>......@......\n",[137,331,329],{"__ignoreMap":139},[15,333,334,335,338],{},"Each pair of hex characters is one byte. If you can read hex, you can spot magic numbers (",[137,336,337],{},"7f 45 4c 46"," = ELF header), string literals, and structure layouts.",[195,340,342],{"id":341},"bitmasks-and-flags","Bitmasks and Flags",[15,344,345],{},"Hex is the standard way to write bitmasks. Each hex digit controls exactly four bits.",[130,347,351],{"className":348,"code":349,"language":350,"meta":139,"style":139},"language-javascript shiki shiki-themes github-light github-dark","const READ    = 0x4;  \u002F\u002F 0100\nconst WRITE   = 0x2;  \u002F\u002F 0010\nconst EXECUTE = 0x1;  \u002F\u002F 0001\n\nconst FULL_ACCESS = READ | WRITE | EXECUTE;  \u002F\u002F 0x7 (0111)\n","javascript",[137,352,353,374,392,411,418],{"__ignoreMap":139},[210,354,355,359,362,365,368,371],{"class":212,"line":213},[210,356,358],{"class":357},"szBVR","const",[210,360,361],{"class":224}," READ",[210,363,364],{"class":357},"    =",[210,366,367],{"class":224}," 0x4",[210,369,370],{"class":220},";  ",[210,372,373],{"class":237},"\u002F\u002F 0100\n",[210,375,376,378,381,384,387,389],{"class":212,"line":241},[210,377,358],{"class":357},[210,379,380],{"class":224}," WRITE",[210,382,383],{"class":357},"   =",[210,385,386],{"class":224}," 0x2",[210,388,370],{"class":220},[210,390,391],{"class":237},"\u002F\u002F 0010\n",[210,393,395,397,400,403,406,408],{"class":212,"line":394},3,[210,396,358],{"class":357},[210,398,399],{"class":224}," EXECUTE",[210,401,402],{"class":357}," =",[210,404,405],{"class":224}," 0x1",[210,407,370],{"class":220},[210,409,410],{"class":237},"\u002F\u002F 0001\n",[210,412,414],{"class":212,"line":413},4,[210,415,417],{"emptyLinePlaceholder":416},true,"\n",[210,419,421,423,426,428,430,433,435,437,439,441],{"class":212,"line":420},5,[210,422,358],{"class":357},[210,424,425],{"class":224}," FULL_ACCESS",[210,427,402],{"class":357},[210,429,361],{"class":224},[210,431,432],{"class":357}," |",[210,434,380],{"class":224},[210,436,432],{"class":357},[210,438,399],{"class":224},[210,440,370],{"class":220},[210,442,443],{"class":237},"\u002F\u002F 0x7 (0111)\n",[10,445,447],{"id":446},"conversion-techniques","Conversion Techniques",[195,449,451],{"id":450},"hex-to-binary-and-back","Hex to Binary (and Back)",[15,453,454],{},"The fastest conversion: replace each hex digit with its 4-bit binary equivalent. Memorize this table and you'll never need a calculator.",[19,456,457,471],{},[22,458,459],{},[25,460,461,464,467,469],{},[28,462,463],{},"Hex",[28,465,466],{},"Binary",[28,468,463],{},[28,470,466],{},[80,472,473,485,497,508,520,532,544,556],{},[25,474,475,477,480,482],{},[85,476,33],{},[85,478,479],{},"0000",[85,481,57],{},[85,483,484],{},"1000",[25,486,487,489,492,494],{},[85,488,36],{},[85,490,491],{},"0001",[85,493,60],{},[85,495,496],{},"1001",[25,498,499,501,504,506],{},[85,500,39],{},[85,502,503],{},"0010",[85,505,63],{},[85,507,185],{},[25,509,510,512,515,517],{},[85,511,42],{},[85,513,514],{},"0011",[85,516,66],{},[85,518,519],{},"1011",[25,521,522,524,527,529],{},[85,523,45],{},[85,525,526],{},"0100",[85,528,69],{},[85,530,531],{},"1100",[25,533,534,536,539,541],{},[85,535,48],{},[85,537,538],{},"0101",[85,540,72],{},[85,542,543],{},"1101",[25,545,546,548,551,553],{},[85,547,51],{},[85,549,550],{},"0110",[85,552,75],{},[85,554,555],{},"1110",[25,557,558,560,563,565],{},[85,559,54],{},[85,561,562],{},"0111",[85,564,78],{},[85,566,181],{},[130,568,571],{"className":569,"code":570,"language":135},[133],"Hex:    3    C    F\nBinary: 0011 1100 1111\n",[137,572,570],{"__ignoreMap":139},[195,574,576],{"id":575},"hex-to-decimal","Hex to Decimal",[15,578,579],{},"Multiply each digit by its place value and add:",[130,581,584],{"className":582,"code":583,"language":135},[133],"0xB2 = 11 × 16¹ + 2 × 16⁰ = 176 + 2 = 178\n",[137,585,583],{"__ignoreMap":139},[15,587,588],{},"For quick mental math, remember these landmarks:",[590,591,592,599,605,611],"ul",{},[593,594,595,598],"li",{},[137,596,597],{},"0x10"," = 16",[593,600,601,604],{},[137,602,603],{},"0x100"," = 256 (one byte)",[593,606,607,610],{},[137,608,609],{},"0x1000"," = 4,096",[593,612,613,616],{},[137,614,615],{},"0xFFFF"," = 65,535 (max 16-bit unsigned)",[195,618,620],{"id":619},"decimal-to-hex","Decimal to Hex",[15,622,623],{},"Divide by 16 repeatedly, collecting remainders:",[130,625,628],{"className":626,"code":627,"language":135},[133],"Decimal 43958 → Hex:\n43958 ÷ 16 = 2747 remainder 6\n2747  ÷ 16 = 171  remainder 11 (B)\n171   ÷ 16 = 10   remainder 11 (B)\n10    ÷ 16 = 0    remainder 10 (A)\nResult: 0xAB B6\n",[137,629,627],{"__ignoreMap":139},[10,631,633],{"id":632},"common-pitfalls","Common Pitfalls",[195,635,637],{"id":636},"case-sensitivity","Case Sensitivity",[15,639,640,641,643,644,647,648,321,650,652],{},"Hex digits A–F can be uppercase or lowercase. ",[137,642,149],{}," and ",[137,645,646],{},"0xff"," are identical. But some systems (particularly CSS) are case-sensitive in other ways, so pick a convention and stick with it. Most style guides prefer uppercase (",[137,649,149],{},[137,651,157],{},").",[195,654,656],{"id":655},"leading-zeros-matter","Leading Zeros Matter",[15,658,659,660,643,663,666,667,669],{},"In hex, ",[137,661,662],{},"0x1",[137,664,665],{},"0x01"," are the same number, but they imply different things. ",[137,668,665],{}," suggests a full byte (8 bits). When working with byte-level data, always pad to the correct width: one byte = two hex digits.",[195,671,673],{"id":672},"confusing-hex-with-decimal","Confusing Hex with Decimal",[15,675,676,677,679,680,682,683,685],{},"The number ",[137,678,110],{}," means ten in decimal but sixteen in hex. Always check the prefix. A missing ",[137,681,145],{}," or ",[137,684,153],{}," can cause silent bugs, especially in configuration files.",[195,687,689],{"id":688},"javascript-octal-trap","JavaScript Octal Trap",[15,691,692,693,696,697,699],{},"In JavaScript, a leading zero on an integer literal used to mean octal in sloppy mode. While modern JS uses ",[137,694,695],{},"0o"," for octal and ",[137,698,145],{}," for hex, legacy code may still surprise you. Always use explicit prefixes.",[130,701,703],{"className":348,"code":702,"language":350,"meta":139,"style":139},"0x10  \u002F\u002F 16 (hex) — intended\n010   \u002F\u002F 8  (octal) — likely a mistake\n",[137,704,705,712],{"__ignoreMap":139},[210,706,707,709],{"class":212,"line":213},[210,708,597],{"class":224},[210,710,711],{"class":237},"  \u002F\u002F 16 (hex) — intended\n",[210,713,714,717],{"class":212,"line":241},[210,715,716],{"class":224},"010",[210,718,719],{"class":237},"   \u002F\u002F 8  (octal) — likely a mistake\n",[10,721,723],{"id":722},"key-takeaways","Key Takeaways",[590,725,726,729,732,735,738,746],{},[593,727,728],{},"Hexadecimal is base-16, using digits 0–9 and A–F",[593,730,731],{},"One hex digit equals exactly four binary digits — this is why hex replaced octal",[593,733,734],{},"You encounter hex in CSS colors, memory addresses, debug output, and byte dumps",[593,736,737],{},"The hex-to-binary table (16 entries) is worth memorizing for daily programming",[593,739,740,741,682,743,745],{},"Always use explicit prefixes (",[137,742,145],{},[137,744,153],{},") to avoid confusion with decimal",[593,747,748],{},"Pad hex values to the correct byte width to prevent subtle bugs",[10,750,752],{"id":751},"try-it-yourself","Try It Yourself",[15,754,755,756,761,762,766],{},"Convert between hex, binary, octal, and decimal using our free ",[757,758,760],"a",{"href":759},"\u002Ftools\u002Fnumber-base","Number Base Converter",". Working with CSS colors? Check the ",[757,763,765],{"href":764},"\u002Ftools\u002Fcolor-converter","Color Converter"," to translate hex colors to RGB and HSL.",[10,768,770],{"id":769},"related-guides","Related Guides",[590,772,773,779],{},[593,774,775],{},[757,776,778],{"href":777},"\u002Fguides\u002Fnumber-systems-explained","Number Systems Explained: Binary, Octal, Decimal, and Hexadecimal",[593,780,781],{},[757,782,784],{"href":783},"\u002Fguides\u002Fbinary-number-system","The Binary Number System: How Computers Think in Zeros and Ones",[786,787,788],"style",{},"html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}",{"title":139,"searchDepth":241,"depth":241,"links":790},[791,792,793,799,804,810,811,812],{"id":12,"depth":241,"text":13},{"id":161,"depth":241,"text":162},{"id":192,"depth":241,"text":193,"children":794},[795,796,797,798],{"id":197,"depth":394,"text":198},{"id":289,"depth":394,"text":290},{"id":313,"depth":394,"text":314},{"id":341,"depth":394,"text":342},{"id":446,"depth":241,"text":447,"children":800},[801,802,803],{"id":450,"depth":394,"text":451},{"id":575,"depth":394,"text":576},{"id":619,"depth":394,"text":620},{"id":632,"depth":241,"text":633,"children":805},[806,807,808,809],{"id":636,"depth":394,"text":637},{"id":655,"depth":394,"text":656},{"id":672,"depth":394,"text":673},{"id":688,"depth":394,"text":689},{"id":722,"depth":241,"text":723},{"id":751,"depth":241,"text":752},{"id":769,"depth":241,"text":770},"2026-05-28","A practical guide to the hexadecimal number system — how it works, where it appears in programming, and conversion methods.","md",{"immutable":416},"\u002Fguides\u002Fhexadecimal-guide",6,{"title":5,"description":814},"guides\u002Fhexadecimal-guide","Zjfr8kFLk-cOne0RcPsIh_0vy-ok_zcwZyy3_u-nFRo",1780401326313]