Skip to content

Commit

Permalink
ascii working
Browse files Browse the repository at this point in the history
  • Loading branch information
rpeddakama committed Sep 9, 2021
1 parent 97d6498 commit 199f36a
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
document.getElementById('hexadecimal').innerHTML = parseInt(binary, 2).toString(16);
// Decimal conversion
document.getElementById('decimal').innerHTML = parseInt(binary, 2).toString();
let asciValue = parseInt(binary, 2);
document.getElementById('ascii').innerHTML = String.fromCharCode(asciValue);
}
//
function decimal_2_base(decimal, base) {
Expand Down Expand Up @@ -77,7 +79,7 @@
const binary = getBits();
setConversions(binary);
}
// add is positive integer, subtract is negative integer
nary // add is positive integer, subtract is negative integer
function add(n) {
let binary = getBits();
// convert to decimal and do math
Expand Down Expand Up @@ -133,6 +135,7 @@ <h1 class="text-center">Binary Math with Conversions</h1>
<th>Octal</th>
<th>Hexadecimal</th>
<th>Decimal</th>
<th>ASCII</th>
<th>Minus</th>
</tr>
<tr>
Expand All @@ -141,6 +144,7 @@ <h1 class="text-center">Binary Math with Conversions</h1>
<td id="octal">0</td>
<td id="hexadecimal">0</td>
<td id="decimal">0</td>
<td id="ascii">N/A</td>
<td><button type="button" id="sub1" onclick="add(-1)">-1</button></td>
</tr>
</table>
Expand Down

0 comments on commit 199f36a

Please sign in to comment.