binary_decimal.html
1 <!DOCTYPE html> 2 <html lang="de"> 3 <head> 4 <meta charset="UTF-8" /> 5 <meta name="viewport" content="width=device-width, initial-scale=1.0" /> 6 <meta http-equiv="onion-location" content="http://bopbopl6lohkl2rts3ltesjnag4hzs4jrx2h6k6etgq5xasbpqekzlqd.onion" /> 7 <title>BOP Wiki: Converting binary / decimal</title> 8 <link rel="stylesheet" href="/assets/stylesheet.css" /> 9 <link rel="icon" type="image/x-icon" href="/assets/img/favicon.png"> 10 </head> 11 <body> 12 <header> 13 <!-- --------------------------------------------------------------------------------------------------------------------------------- --> 14 <script src="/assets/js/navbar-OpenClose.js"></script> 15 <script src="/assets/js/lightbox.js"></script> 16 <script src="/assets/js/copyCodeButton.js"></script> 17 <link rel="stylesheet" href="/resources/js-libraries/highlightJS/atom-one-dark.min.css"> 18 <script src="/resources/js-libraries/highlightJS/highlight.min.js"></script> 19 <script src="/resources/js-libraries/highlightJS/highlightjs-line-numbers.min.js"></script> 20 <script>hljs.highlightAll();</script> 21 <script>hljs.initLineNumbersOnLoad();</script> 22 <!-- --------------------------------------------------------------------------------------------------------------------------------- --> 23 <div class="branding"> 24 <button class="toggle-btn-navbar" id="navbarOpenButton">☰</button> 25 <a href="/"> 26 <img class="logo" src="/assets/img/logo.png"> 27 </a> 28 <div class="typing-animation">BytesOfProgress</div> 29 </div> 30 </header> 31 <div id="navbarContainer" class="navbar-container"> 32 <iframe class="navbar-iframe" src="/assets/navbar/navbar.html" frameBorder= "0"></iframe> 33 </div> 34 <main> 35 <!-- --------------------------------------------------------------------------------------------------------------------------------- --> 36 <article class="site-post"> 37 <header class="post-header"> 38 <h1 class="post-title">Converting binary / decimal</h1> 39 <div class="post-meta"> 40 </div> 41 </header> 42 </article> 43 <nav class="breadcrumb"> 44 <a href="/">Home</a> 45 <span class="divider">›</span> 46 <a href="/wiki/">Wiki</a> 47 <span class="divider">›</span> 48 <a href="/wiki/math/math.html">Mathematics</a> 49 <span class="divider">›</span> 50 <a href="/wiki/math/numbersystems/numbersystems.html">Numbersystems</a> 51 <span class="divider">›</span> 52 <span class="current">Converting binary / decimal</span> 53 </nav> 54 <section class="post-content"> 55 <!-- --------------------------------------------------------------------------------------------------------------------------------- --> 56 <h1 style="font-size:30px; color:#ff6600;">Converting Decimal to Binary:</h1> 57 <img style="max-width:95%; width: 500px;" src="task1.png" alt="Decimal to Binary Conversion Process"/> 58 <p> 59 To convert a decimal number to binary, we first need to create a table that represents the binary "bits" corresponding to powers of 2. 60 </p> 61 <img style="max-width:95%; width: 500px;" src="1.png" alt="Bit Table for Conversion"/> 62 <p> 63 Next, identify the smallest number in the table that is larger than or equal to your decimal number. For example, in this case, we are converting <strong>239</strong>. The smallest number in the table that fits 239 is <strong>256</strong>. This means 256 gets a "0" in the binary result, while <strong>128</strong> gets a "1." 64 </p> 65 <img style="max-width:95%; width: 500px;" src="2.png" alt="Identifying Relevant Bits"/> 66 <p> 67 After subtracting <strong>128</strong> from <strong>239</strong>, we are left with <strong>111</strong>. Now, we need to "build" the number 111 using smaller numbers in the table (64, 32, 16, 8, 4, 2, 1). 68 </p> 69 <p> 70 <strong>Hint:</strong> If the decimal number is odd, the rightmost bit in the binary representation will always be "1". For example: 71 </p> 72 <p> 73 <strong>239</strong> is odd, so its binary representation ends with "1": 74 <br> <strong>239 = xxxxxxx1</strong> 75 </p> 76 <p> 77 <strong>238</strong> is even, so its binary representation ends with "0": 78 <br> <strong>238 = xxxxxxx0</strong> 79 </p> 80 <p> 81 After "building" 111, we can now fill in the binary bits: 82 </p> 83 <img style="max-width:95%; width: 500px;" src="3.png" alt="Building the Binary Representation"/> 84 <p> 85 So, <strong>239</strong> in decimal equals <strong>11101111</strong> in binary because: 86 <br> 128 + 64 + 32 + 8 + 4 + 2 + 1 = 239 87 </p> 88 <p><strong>Additional Notes:</strong></p> 89 <p> 90 1. Always start counting from zero when creating a binary table: 91 </p> 92 <img style="max-width:95%; width: 350px;" src="4.png" alt="Binary Counting Starting from Zero"/> 93 <p> 94 2. The highest representable number for each bit length is one less than the next bit length: 95 </p> 96 <p> 97 - 8 bits: 255 98 <br> - 9 bits: 511 99 <br> - 4 bits: 15 100 </p> 101 <hr> 102 <!-- --------------------------------------------------------------------------------------------------------------------------------- --> 103 <h1 style="font-size:30px; color:#ff6600;">Converting Binary to Decimal:</h1> 104 <img style="max-width:95%; width: 500px;" src="task2.png" alt="Binary to Decimal Conversion Process"/> 105 <p> 106 To convert a binary number back to decimal, we once again need to set up a "bit table" representing powers of 2. 107 </p> 108 <img style="max-width:95%; width: 500px;" src="5.png" alt="Binary Bit Table for Conversion"/> 109 <p> 110 Write the binary digits in the table, starting from the rightmost side and moving left. This will help us identify which powers of 2 are included in the sum. 111 </p> 112 <img style="max-width:95%; width: 500px;" src="6.png" alt="Filling the Bit Table with Binary Values"/> 113 <p> 114 Now, add up the values of the positions where there is a "1". In this case, we have: 115 </p> 116 <p> 117 <strong>128 + 64 + 32 + 8 + 4 + 2 + 1 = 239</strong> 118 </p> 119 <p> 120 Therefore, <strong>11101111</strong> in binary equals <strong>239</strong> in decimal. 121 </p> 122 <br> 123 <p> 124 Congratulations! You now know how to convert between decimal and binary numbers. 125 </p> 126 </section> 127 <footer class="post-footer"> 128 <a href="/wiki/math/numbersystems/numbersystems.html" class="cta-button">← Back</a> 129 </footer> 130 </main> 131 </body> 132 </html>