[{"data":1,"prerenderedAt":554},["ShallowReactive",2],{"guide-number-systems-explained":3},{"id":4,"title":5,"body":6,"date":546,"description":547,"extension":548,"meta":549,"navigation":369,"path":550,"readingTime":379,"seo":551,"stem":552,"__hash__":553},"guides\u002Fguides\u002Fnumber-systems-explained.md","Number Systems Explained: Binary, Octal, Decimal, and Hexadecimal",{"type":7,"value":8,"toc":523},"minimark",[9,14,18,21,77,93,97,102,105,115,118,122,125,131,134,138,141,147,154,158,161,167,170,174,248,252,256,259,265,269,272,278,282,285,291,294,298,302,305,421,425,432,438,442,445,462,466,488,492,501,505,519],[10,11,13],"h2",{"id":12},"what-is-a-number-system","What Is a Number System?",[15,16,17],"p",{},"A number system is a way to represent quantities using a fixed set of symbols and rules. The system you use every day — decimal — uses ten digits (0–9) because humans have ten fingers. But computers don't have fingers. They have transistors, which understand only two states: on and off. That's why different number systems exist.",[15,19,20],{},"Every number system has three key components:",[22,23,24,40],"table",{},[25,26,27],"thead",{},[28,29,30,34,37],"tr",{},[31,32,33],"th",{},"Component",[31,35,36],{},"Definition",[31,38,39],{},"Decimal Example",[41,42,43,55,66],"tbody",{},[28,44,45,49,52],{},[46,47,48],"td",{},"Base (radix)",[46,50,51],{},"The number of unique digits",[46,53,54],{},"10",[28,56,57,60,63],{},[46,58,59],{},"Digits",[46,61,62],{},"The symbols used to represent values",[46,64,65],{},"0, 1, 2, ..., 9",[28,67,68,71,74],{},[46,69,70],{},"Place value",[46,72,73],{},"The weight of each position, calculated as base^position",[46,75,76],{},"10^0, 10^1, 10^2",[15,78,79,80,84,85,88,89,92],{},"The same number looks different depending on the base. The value 255 in decimal is ",[81,82,83],"code",{},"11111111"," in binary, ",[81,86,87],{},"377"," in octal, and ",[81,90,91],{},"FF"," in hexadecimal — but it represents the exact same quantity.",[10,94,96],{"id":95},"the-four-common-number-systems","The Four Common Number Systems",[98,99,101],"h3",{"id":100},"decimal-base-10","Decimal (Base-10)",[15,103,104],{},"Decimal is the number system you already know. It uses digits 0 through 9, and each position represents a power of 10.",[106,107,112],"pre",{"className":108,"code":110,"language":111},[109],"language-text","345 = 3 × 10² + 4 × 10¹ + 5 × 10⁰\n    = 300 + 40 + 5\n    = 345\n","text",[81,113,110],{"__ignoreMap":114},"",[15,116,117],{},"You use decimal for everyday counting, money, and measurements. In programming, decimal is the default for human-readable output.",[98,119,121],{"id":120},"binary-base-2","Binary (Base-2)",[15,123,124],{},"Binary uses only two digits: 0 and 1. Each position represents a power of 2. This is the native language of computers — every piece of data in memory is stored as binary.",[106,126,129],{"className":127,"code":128,"language":111},[109],"1011 = 1 × 2³ + 0 × 2² + 1 × 2¹ + 1 × 2⁰\n     = 8 + 0 + 2 + 1\n     = 11 (decimal)\n",[81,130,128],{"__ignoreMap":114},[15,132,133],{},"Common uses of binary in programming include bitmasks, permission flags, and low-level hardware control.",[98,135,137],{"id":136},"octal-base-8","Octal (Base-8)",[15,139,140],{},"Octal uses digits 0 through 7. Each position represents a power of 8. Octal was popular in early computing when systems used 12-bit or 36-bit word sizes, because those divide evenly by 3.",[106,142,145],{"className":143,"code":144,"language":111},[109],"72 = 7 × 8¹ + 2 × 8⁰\n   = 56 + 2\n   = 58 (decimal)\n",[81,146,144],{"__ignoreMap":114},[15,148,149,150,153],{},"Today, octal appears most often in Unix file permissions. The command ",[81,151,152],{},"chmod 755"," sets permissions using octal digits where each digit represents read, write, and execute bits for owner, group, and others.",[98,155,157],{"id":156},"hexadecimal-base-16","Hexadecimal (Base-16)",[15,159,160],{},"Hexadecimal (hex) uses sixteen digits: 0–9 and A–F. The letters A through F represent decimal values 10 through 15. Each position represents a power of 16.",[106,162,165],{"className":163,"code":164,"language":111},[109],"2F = 2 × 16¹ + 15 × 16⁰\n   = 32 + 15\n   = 47 (decimal)\n",[81,166,164],{"__ignoreMap":114},[15,168,169],{},"Hex is the go-to format for representing binary data compactly. One hex digit maps exactly to four binary digits, making conversion between the two trivial.",[10,171,173],{"id":172},"comparing-the-systems","Comparing the Systems",[22,175,176,191],{},[25,177,178],{},[28,179,180,183,186,188],{},[31,181,182],{},"System",[31,184,185],{},"Base",[31,187,59],{},[31,189,190],{},"Typical Use",[41,192,193,207,221,234],{},[28,194,195,198,201,204],{},[46,196,197],{},"Binary",[46,199,200],{},"2",[46,202,203],{},"0, 1",[46,205,206],{},"Logic gates, bitmasks, low-level hardware",[28,208,209,212,215,218],{},[46,210,211],{},"Octal",[46,213,214],{},"8",[46,216,217],{},"0–7",[46,219,220],{},"Unix file permissions",[28,222,223,226,228,231],{},[46,224,225],{},"Decimal",[46,227,54],{},[46,229,230],{},"0–9",[46,232,233],{},"Human-readable output, everyday math",[28,235,236,239,242,245],{},[46,237,238],{},"Hexadecimal",[46,240,241],{},"16",[46,243,244],{},"0–9, A–F",[46,246,247],{},"Memory addresses, color values, debugging",[10,249,251],{"id":250},"conversion-methods","Conversion Methods",[98,253,255],{"id":254},"converting-from-any-base-to-decimal","Converting from Any Base to Decimal",[15,257,258],{},"Multiply each digit by its place value (base raised to the position power) and add the results. This works for every base.",[106,260,263],{"className":261,"code":262,"language":111},[109],"Binary 1101 → Decimal:\n1×2³ + 1×2² + 0×2¹ + 1×2⁰ = 8 + 4 + 0 + 1 = 13\n\nHex 3A → Decimal:\n3×16¹ + 10×16⁰ = 48 + 10 = 58\n",[81,264,262],{"__ignoreMap":114},[98,266,268],{"id":267},"converting-from-decimal-to-any-base","Converting from Decimal to Any Base",[15,270,271],{},"Divide the decimal number by the target base repeatedly. Collect the remainders in reverse order.",[106,273,276],{"className":274,"code":275,"language":111},[109],"Decimal 255 → Binary:\n255 ÷ 2 = 127 remainder 1\n127 ÷ 2 = 63  remainder 1\n63  ÷ 2 = 31  remainder 1\n31  ÷ 2 = 15  remainder 1\n15  ÷ 2 = 7   remainder 1\n7   ÷ 2 = 3   remainder 1\n3   ÷ 2 = 1   remainder 1\n1   ÷ 2 = 0   remainder 1\nResult (read bottom-up): 11111111\n\nDecimal 255 → Hex:\n255 ÷ 16 = 15 remainder 15 (F)\n15  ÷ 16 = 0  remainder 15 (F)\nResult: FF\n",[81,277,275],{"__ignoreMap":114},[98,279,281],{"id":280},"binary-hex-shortcut","Binary ↔ Hex Shortcut",[15,283,284],{},"This is the conversion trick developers use most often. Group binary digits in sets of four (from right to left), then replace each group with its hex equivalent.",[106,286,289],{"className":287,"code":288,"language":111},[109],"Binary: 1101 0110 0011\nHex:      D    6    3\nResult: D63\n",[81,290,288],{"__ignoreMap":114},[15,292,293],{},"No long division needed — just memorize the 16 possible 4-bit patterns and their hex equivalents.",[10,295,297],{"id":296},"number-systems-in-programming","Number Systems in Programming",[98,299,301],{"id":300},"bitmasks-and-permissions","Bitmasks and Permissions",[15,303,304],{},"Many APIs use bit positions to represent flags. Understanding binary lets you read and set these values directly.",[106,306,310],{"className":307,"code":308,"language":309,"meta":114,"style":114},"language-javascript shiki shiki-themes github-light github-dark","\u002F\u002F Read permission = 4 (100), Write = 2 (010), Execute = 1 (001)\nconst READ_WRITE = 0b110;  \u002F\u002F 6\nconst ALL = 0b111;          \u002F\u002F 7\n\n\u002F\u002F Check if read is set\nif (permissions & 0b100) {\n  console.log(\"Read access granted\");\n}\n","javascript",[81,311,312,321,345,364,371,377,395,415],{"__ignoreMap":114},[313,314,317],"span",{"class":315,"line":316},"line",1,[313,318,320],{"class":319},"sJ8bj","\u002F\u002F Read permission = 4 (100), Write = 2 (010), Execute = 1 (001)\n",[313,322,324,328,332,335,338,342],{"class":315,"line":323},2,[313,325,327],{"class":326},"szBVR","const",[313,329,331],{"class":330},"sj4cs"," READ_WRITE",[313,333,334],{"class":326}," =",[313,336,337],{"class":330}," 0b110",[313,339,341],{"class":340},"sVt8B",";  ",[313,343,344],{"class":319},"\u002F\u002F 6\n",[313,346,348,350,353,355,358,361],{"class":315,"line":347},3,[313,349,327],{"class":326},[313,351,352],{"class":330}," ALL",[313,354,334],{"class":326},[313,356,357],{"class":330}," 0b111",[313,359,360],{"class":340},";          ",[313,362,363],{"class":319},"\u002F\u002F 7\n",[313,365,367],{"class":315,"line":366},4,[313,368,370],{"emptyLinePlaceholder":369},true,"\n",[313,372,374],{"class":315,"line":373},5,[313,375,376],{"class":319},"\u002F\u002F Check if read is set\n",[313,378,380,383,386,389,392],{"class":315,"line":379},6,[313,381,382],{"class":326},"if",[313,384,385],{"class":340}," (permissions ",[313,387,388],{"class":326},"&",[313,390,391],{"class":330}," 0b100",[313,393,394],{"class":340},") {\n",[313,396,398,401,405,408,412],{"class":315,"line":397},7,[313,399,400],{"class":340},"  console.",[313,402,404],{"class":403},"sScJk","log",[313,406,407],{"class":340},"(",[313,409,411],{"class":410},"sZZnC","\"Read access granted\"",[313,413,414],{"class":340},");\n",[313,416,418],{"class":315,"line":417},8,[313,419,420],{"class":340},"}\n",[98,422,424],{"id":423},"css-color-values","CSS Color Values",[15,426,427,428,431],{},"CSS colors like ",[81,429,430],{},"#FF5733"," are hexadecimal. Each pair of hex digits represents the red, green, or blue channel from 0 to 255.",[106,433,436],{"className":434,"code":435,"language":111},[109],"#FF5733\nRR = FF = 255 (red)\nGG = 57 = 87  (green)\nBB = 33 = 51  (blue)\n",[81,437,435],{"__ignoreMap":114},[98,439,441],{"id":440},"memory-addresses","Memory Addresses",[15,443,444],{},"Debuggers and profilers display memory addresses in hex. Understanding hex helps you spot patterns and alignment issues in memory dumps.",[106,446,450],{"className":447,"code":448,"language":449,"meta":114,"style":114},"language-c shiki shiki-themes github-light github-dark","\u002F\u002F Typical memory address output\n0x7fff5fbff8a0  \u002F\u002F hex address\n","c",[81,451,452,457],{"__ignoreMap":114},[313,453,454],{"class":315,"line":316},[313,455,456],{},"\u002F\u002F Typical memory address output\n",[313,458,459],{"class":315,"line":323},[313,460,461],{},"0x7fff5fbff8a0  \u002F\u002F hex address\n",[10,463,465],{"id":464},"key-takeaways","Key Takeaways",[467,468,469,473,476,479,482,485],"ul",{},[470,471,472],"li",{},"Every number system uses a base, a set of digits, and place values based on powers of the base",[470,474,475],{},"Binary is fundamental to computing; decimal is for humans; hex bridges the two",[470,477,478],{},"Octal survives mainly in Unix file permissions",[470,480,481],{},"The divide-by-base method converts decimal to any base; multiply-by-place-value converts any base to decimal",[470,483,484],{},"The binary-to-hex shortcut (group 4 bits) is the most practical conversion for daily programming",[470,486,487],{},"Hex appears everywhere: CSS colors, memory addresses, debug output, and byte representations",[10,489,491],{"id":490},"try-it-yourself","Try It Yourself",[15,493,494,495,500],{},"Ready to practice base conversions? Use our free ",[496,497,499],"a",{"href":498},"\u002Ftools\u002Fnumber-base","Number Base Converter"," to convert between binary, octal, decimal, and hexadecimal instantly.",[10,502,504],{"id":503},"related-guides","Related Guides",[467,506,507,513],{},[470,508,509],{},[496,510,512],{"href":511},"\u002Fguides\u002Fhexadecimal-guide","Hexadecimal Guide: Why Developers Use Base-16 Every Day",[470,514,515],{},[496,516,518],{"href":517},"\u002Fguides\u002Fbinary-number-system","The Binary Number System: How Computers Think in Zeros and Ones",[520,521,522],"style",{},"html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}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);}",{"title":114,"searchDepth":323,"depth":323,"links":524},[525,526,532,533,538,543,544,545],{"id":12,"depth":323,"text":13},{"id":95,"depth":323,"text":96,"children":527},[528,529,530,531],{"id":100,"depth":347,"text":101},{"id":120,"depth":347,"text":121},{"id":136,"depth":347,"text":137},{"id":156,"depth":347,"text":157},{"id":172,"depth":323,"text":173},{"id":250,"depth":323,"text":251,"children":534},[535,536,537],{"id":254,"depth":347,"text":255},{"id":267,"depth":347,"text":268},{"id":280,"depth":347,"text":281},{"id":296,"depth":323,"text":297,"children":539},[540,541,542],{"id":300,"depth":347,"text":301},{"id":423,"depth":347,"text":424},{"id":440,"depth":347,"text":441},{"id":464,"depth":323,"text":465},{"id":490,"depth":323,"text":491},{"id":503,"depth":323,"text":504},"2026-05-28","Learn how binary, octal, decimal, and hexadecimal number systems work, and why developers need to understand base conversions.","md",{"immutable":369},"\u002Fguides\u002Fnumber-systems-explained",{"title":5,"description":547},"guides\u002Fnumber-systems-explained","2Fvu8_wvkmz8VXWzYlBRtmJKkv-V4KPlcVccE3175iA",1780401326267]