[{"data":1,"prerenderedAt":650},["ShallowReactive",2],{"guide-binary-number-system":3},{"id":4,"title":5,"body":6,"date":642,"description":643,"extension":644,"meta":645,"navigation":296,"path":646,"readingTime":306,"seo":647,"stem":648,"__hash__":649},"guides\u002Fguides\u002Fbinary-number-system.md","Binary Number System - How Binary Works in Computing",{"type":7,"value":8,"toc":618},"minimark",[9,14,23,34,37,41,44,111,114,118,121,126,132,139,143,146,152,156,159,165,169,173,176,180,183,189,200,203,209,213,224,228,231,237,244,248,252,363,367,411,415,506,510,513,519,522,525,543,547,564,568,584,588,614],[10,11,13],"h2",{"id":12},"what-is-the-binary-number-system","What Is the Binary Number System?",[15,16,17,18,22],"p",{},"The binary number system is a base-2 numeral system that uses exactly two digits: 0 and 1. Each digit — called a ",[19,20,21],"strong",{},"bit"," — represents a power of 2, just as each decimal digit represents a power of 10.",[24,25,30],"pre",{"className":26,"code":28,"language":29},[27],"language-text","1011 = 1 × 2³ + 0 × 2² + 1 × 2¹ + 1 × 2⁰\n     = 8 + 0 + 2 + 1\n     = 11 (decimal)\n","text",[31,32,28],"code",{"__ignoreMap":33},"",[15,35,36],{},"Binary isn't just a convenient encoding choice. It mirrors the physical behavior of transistors — the microscopic switches inside every processor. A transistor conducts or blocks current: two states, naturally represented as 1 and 0.",[10,38,40],{"id":39},"binary-vs-decimal","Binary vs Decimal",[15,42,43],{},"Both systems work the same way — they just use different bases:",[45,46,47,63],"table",{},[48,49,50],"thead",{},[51,52,53,57,60],"tr",{},[54,55,56],"th",{},"Property",[54,58,59],{},"Decimal (Base-10)",[54,61,62],{},"Binary (Base-2)",[64,65,66,78,89,100],"tbody",{},[51,67,68,72,75],{},[69,70,71],"td",{},"Digits",[69,73,74],{},"0, 1, 2, ..., 9",[69,76,77],{},"0, 1",[51,79,80,83,86],{},[69,81,82],{},"Place values",[69,84,85],{},"10⁰, 10¹, 10², …",[69,87,88],{},"2⁰, 2¹, 2², …",[51,90,91,94,97],{},[69,92,93],{},"Example number",[69,95,96],{},"42",[69,98,99],{},"101010",[51,101,102,105,108],{},[69,103,104],{},"Largest 3-digit",[69,106,107],{},"999",[69,109,110],{},"111 (= 7)",[15,112,113],{},"Decimal feels natural because humans have ten fingers. Binary feels natural to hardware because digital circuits have two voltage states. Every other number system — octal, hexadecimal — is just a more compact way for humans to read binary.",[10,115,117],{"id":116},"how-to-convert-decimal-to-binary","How to Convert Decimal to Binary",[15,119,120],{},"The standard method: divide by 2, record the remainder, and read remainders bottom-up.",[122,123,125],"h3",{"id":124},"example-convert-156-to-binary","Example: Convert 156 to Binary",[24,127,130],{"className":128,"code":129,"language":29},[27],"156 ÷ 2 = 78  remainder 0\n 78 ÷ 2 = 39  remainder 0\n 39 ÷ 2 = 19  remainder 1\n 19 ÷ 2 = 9   remainder 1\n  9 ÷ 2 = 4   remainder 1\n  4 ÷ 2 = 2   remainder 0\n  2 ÷ 2 = 1   remainder 0\n  1 ÷ 2 = 0   remainder 1\n\nRead bottom-up: 10011100\n",[31,131,129],{"__ignoreMap":33},[15,133,134,135,138],{},"Verify: ",[31,136,137],{},"128 + 16 + 8 + 4 = 156"," ✓",[122,140,142],{"id":141},"shortcut-power-of-2-subtraction","Shortcut: Power-of-2 Subtraction",[15,144,145],{},"Find the largest power of 2 that fits, subtract, and repeat:",[24,147,150],{"className":148,"code":149,"language":29},[27],"156 - 128 = 28  → bit 7 = 1\n 28 -  16 = 12  → bit 4 = 1\n 12 -   8 = 4   → bit 3 = 1\n  4 -   4 = 0   → bit 2 = 1\nAll other bits = 0\n\nResult: 10011100 (same as above)\n",[31,151,149],{"__ignoreMap":33},[10,153,155],{"id":154},"how-to-convert-binary-to-decimal","How to Convert Binary to Decimal",[15,157,158],{},"Multiply each bit by its place value and sum:",[24,160,163],{"className":161,"code":162,"language":29},[27],"Binary: 1 0 0 1 1 1 0 0\nPlace:  7 6 5 4 3 2 1 0\n\n1×128 + 0×64 + 0×32 + 1×16 + 1×8 + 1×4 + 0×2 + 0×1\n= 128 + 16 + 8 + 4\n= 156\n",[31,164,162],{"__ignoreMap":33},[10,166,168],{"id":167},"binary-in-computer-science","Binary in Computer Science",[122,170,172],{"id":171},"memory-addressing","Memory Addressing",[15,174,175],{},"Memory is addressed in bytes (8 bits). A 32-bit processor can address 2³² = 4,294,967,296 bytes (4 GB). A 64-bit processor can address 2⁶⁴ bytes — far more than any current system needs.",[122,177,179],{"id":178},"ip-addresses","IP Addresses",[15,181,182],{},"IPv4 addresses are 32-bit binary numbers, written as four decimal octets for readability:",[24,184,187],{"className":185,"code":186,"language":29},[27],"Binary:  11000000 10101000 00000001 00000001\nDecimal: 192.168.1.1\n",[31,188,186],{"__ignoreMap":33},[15,190,191,192,195,196,199],{},"Each octet ranges from ",[31,193,194],{},"00000000"," (0) to ",[31,197,198],{},"11111111"," (255). That's why no IPv4 octet exceeds 255.",[15,201,202],{},"Subnet masks are pure binary logic — an AND operation between the IP address and the mask yields the network address:",[24,204,207],{"className":205,"code":206,"language":29},[27],"IP:    11000000.10101000.00000001.00000001  (192.168.1.1)\nMask:  11111111.11111111.11111111.00000000  (255.255.255.0)\nAND:   11000000.10101000.00000001.00000000  (192.168.1.0)\n",[31,208,206],{"__ignoreMap":33},[122,210,212],{"id":211},"color-values","Color Values",[15,214,215,216,219,220,223],{},"RGB colors use three bytes — one for red, one for green, one for blue. Pure red is ",[31,217,218],{},"11111111 00000000 00000000",", or ",[31,221,222],{},"#FF0000"," in hex. Each channel's 8 bits give 256 intensity levels (0–255), yielding 16,777,216 possible colors.",[122,225,227],{"id":226},"file-permissions-unix","File Permissions (Unix)",[15,229,230],{},"File permissions use 3 bits per role (read, write, execute):",[24,232,235],{"className":233,"code":234,"language":29},[27],"rwx r-x r-- = 111 101 100 = 7 5 4\n",[31,236,234],{"__ignoreMap":33},[15,238,239,240,243],{},"That's where ",[31,241,242],{},"chmod 754"," comes from — each octal digit represents 3 binary permission bits.",[10,245,247],{"id":246},"binary-representation-in-code","Binary Representation in Code",[122,249,251],{"id":250},"javascript","JavaScript",[24,253,256],{"className":254,"code":255,"language":250,"meta":33,"style":33},"language-javascript shiki shiki-themes github-light github-dark","\u002F\u002F Binary literal (ES6+)\nconst mask = 0b11110000;  \u002F\u002F 240\n\n\u002F\u002F Convert to binary string\n(42).toString(2);  \u002F\u002F \"101010\"\n\n\u002F\u002F Parse binary string\nparseInt('101010', 2);  \u002F\u002F 42\n",[31,257,258,267,291,298,304,330,335,341],{"__ignoreMap":33},[259,260,263],"span",{"class":261,"line":262},"line",1,[259,264,266],{"class":265},"sJ8bj","\u002F\u002F Binary literal (ES6+)\n",[259,268,270,274,278,281,284,288],{"class":261,"line":269},2,[259,271,273],{"class":272},"szBVR","const",[259,275,277],{"class":276},"sj4cs"," mask",[259,279,280],{"class":272}," =",[259,282,283],{"class":276}," 0b11110000",[259,285,287],{"class":286},"sVt8B",";  ",[259,289,290],{"class":265},"\u002F\u002F 240\n",[259,292,294],{"class":261,"line":293},3,[259,295,297],{"emptyLinePlaceholder":296},true,"\n",[259,299,301],{"class":261,"line":300},4,[259,302,303],{"class":265},"\u002F\u002F Convert to binary string\n",[259,305,307,310,312,315,319,321,324,327],{"class":261,"line":306},5,[259,308,309],{"class":286},"(",[259,311,96],{"class":276},[259,313,314],{"class":286},").",[259,316,318],{"class":317},"sScJk","toString",[259,320,309],{"class":286},[259,322,323],{"class":276},"2",[259,325,326],{"class":286},");  ",[259,328,329],{"class":265},"\u002F\u002F \"101010\"\n",[259,331,333],{"class":261,"line":332},6,[259,334,297],{"emptyLinePlaceholder":296},[259,336,338],{"class":261,"line":337},7,[259,339,340],{"class":265},"\u002F\u002F Parse binary string\n",[259,342,344,347,349,353,356,358,360],{"class":261,"line":343},8,[259,345,346],{"class":317},"parseInt",[259,348,309],{"class":286},[259,350,352],{"class":351},"sZZnC","'101010'",[259,354,355],{"class":286},", ",[259,357,323],{"class":276},[259,359,326],{"class":286},[259,361,362],{"class":265},"\u002F\u002F 42\n",[122,364,366],{"id":365},"python","Python",[24,368,371],{"className":369,"code":370,"language":365,"meta":33,"style":33},"language-python shiki shiki-themes github-light github-dark","# Binary literal\nmask = 0b11110000  # 240\n\n# Convert to binary string\nbin(42)  # '0b101010'\n\n# Parse binary string\nint('101010', 2)  # 42\n",[31,372,373,378,383,387,392,397,401,406],{"__ignoreMap":33},[259,374,375],{"class":261,"line":262},[259,376,377],{},"# Binary literal\n",[259,379,380],{"class":261,"line":269},[259,381,382],{},"mask = 0b11110000  # 240\n",[259,384,385],{"class":261,"line":293},[259,386,297],{"emptyLinePlaceholder":296},[259,388,389],{"class":261,"line":300},[259,390,391],{},"# Convert to binary string\n",[259,393,394],{"class":261,"line":306},[259,395,396],{},"bin(42)  # '0b101010'\n",[259,398,399],{"class":261,"line":332},[259,400,297],{"emptyLinePlaceholder":296},[259,402,403],{"class":261,"line":337},[259,404,405],{},"# Parse binary string\n",[259,407,408],{"class":261,"line":343},[259,409,410],{},"int('101010', 2)  # 42\n",[10,412,414],{"id":413},"common-binary-patterns","Common Binary Patterns",[45,416,417,430],{},[48,418,419],{},[51,420,421,424,427],{},[54,422,423],{},"Binary Pattern",[54,425,426],{},"Decimal",[54,428,429],{},"Meaning",[64,431,432,442,452,463,474,485,496],{},[51,433,434,436,439],{},[69,435,194],{},[69,437,438],{},"0",[69,440,441],{},"Minimum byte value",[51,443,444,446,449],{},[69,445,198],{},[69,447,448],{},"255",[69,450,451],{},"Maximum byte value",[51,453,454,457,460],{},[69,455,456],{},"10000000",[69,458,459],{},"128",[69,461,462],{},"MSB set (sign bit in signed ints)",[51,464,465,468,471],{},[69,466,467],{},"00001111",[69,469,470],{},"15",[69,472,473],{},"Low nibble mask",[51,475,476,479,482],{},[69,477,478],{},"11110000",[69,480,481],{},"240",[69,483,484],{},"High nibble mask",[51,486,487,490,493],{},[69,488,489],{},"01010101",[69,491,492],{},"85",[69,494,495],{},"Alternating bits",[51,497,498,501,504],{},[69,499,500],{},"10101010",[69,502,503],{},"170",[69,505,495],{},[10,507,509],{"id":508},"signed-numbers-twos-complement","Signed Numbers: Two's Complement",[15,511,512],{},"Computers represent negative integers using two's complement. To negate a number: flip all bits, then add 1.",[24,514,517],{"className":515,"code":516,"language":29},[27],"+5 = 00000101\nFlip: 11111010\nAdd 1: 11111011 = -5\n",[31,518,516],{"__ignoreMap":33},[15,520,521],{},"Two's complement makes subtraction identical to addition — the CPU doesn't need separate subtract circuitry. The leftmost bit (MSB) acts as the sign bit: 0 for positive, 1 for negative.",[15,523,524],{},"In an 8-bit signed integer:",[526,527,528,532,537],"ul",{},[529,530,531],"li",{},"Range: -128 to +127",[529,533,534,536],{},[31,535,456],{}," = -128 (the most negative value)",[529,538,539,542],{},[31,540,541],{},"01111111"," = +127 (the most positive value)",[10,544,546],{"id":545},"key-takeaways","Key Takeaways",[526,548,549,552,555,558,561],{},[529,550,551],{},"Binary is base-2: only digits 0 and 1, with place values as powers of 2",[529,553,554],{},"Convert decimal to binary by dividing by 2 and collecting remainders",[529,556,557],{},"IP addresses, RGB colors, and file permissions all rely on binary representations",[529,559,560],{},"Two's complement elegantly handles signed integers without special subtraction logic",[529,562,563],{},"Hexadecimal is simply a compact way to write binary — each hex digit maps to exactly 4 bits",[10,565,567],{"id":566},"try-it-yourself","Try It Yourself",[15,569,570,571,576,577,583],{},"Practice binary, octal, decimal, and hex conversions with our free ",[572,573,575],"a",{"href":574},"\u002Ftools\u002Fnumber-base","Number Base Converter",". Encode text to binary with the ",[572,578,582],{"href":579,"rel":580},"https:\u002F\u002Ftoolboxes.site\u002Ftools\u002Ftext-binary",[581],"nofollow","Text to Binary converter",".",[10,585,587],{"id":586},"related-guides","Related Guides",[526,589,590,596,602,608],{},[529,591,592],{},[572,593,595],{"href":594},"\u002Fguides\u002Ftext-binary-conversion-guide","Text to Binary Guide - How Text Encoding to Binary Works",[529,597,598],{},[572,599,601],{"href":600},"\u002Fguides\u002Fdata-encoding-tools","Data Encoding Tools - Essential Online Encoders",[529,603,604],{},[572,605,607],{"href":606},"\u002Fguides\u002Fnumber-systems-explained","Number Systems Explained: Binary, Octal, Decimal, and Hexadecimal",[529,609,610],{},[572,611,613],{"href":612},"\u002Fguides\u002Fhexadecimal-guide","Hexadecimal Guide: Why Developers Use Base-16 Every Day",[615,616,617],"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":33,"searchDepth":269,"depth":269,"links":619},[620,621,622,626,627,633,637,638,639,640,641],{"id":12,"depth":269,"text":13},{"id":39,"depth":269,"text":40},{"id":116,"depth":269,"text":117,"children":623},[624,625],{"id":124,"depth":293,"text":125},{"id":141,"depth":293,"text":142},{"id":154,"depth":269,"text":155},{"id":167,"depth":269,"text":168,"children":628},[629,630,631,632],{"id":171,"depth":293,"text":172},{"id":178,"depth":293,"text":179},{"id":211,"depth":293,"text":212},{"id":226,"depth":293,"text":227},{"id":246,"depth":269,"text":247,"children":634},[635,636],{"id":250,"depth":293,"text":251},{"id":365,"depth":293,"text":366},{"id":413,"depth":269,"text":414},{"id":508,"depth":269,"text":509},{"id":545,"depth":269,"text":546},{"id":566,"depth":269,"text":567},{"id":586,"depth":269,"text":587},"2026-05-28","Complete guide to the binary number system. Learn how binary digits work and why computers use base-2.","md",{"immutable":296},"\u002Fguides\u002Fbinary-number-system",{"title":5,"description":643},"guides\u002Fbinary-number-system","c4sv13Gf1C40MJluh2ffmSUFJC76E8xhHQUKxL5bYGs",1780401326337]