Skip to content

Commit

Permalink
Force octal numbers to begin with 7
Browse files Browse the repository at this point in the history
  • Loading branch information
Daghall committed Aug 25, 2024
1 parent ddbe713 commit b088206
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion gui.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const properties = {};

const numeralSystems = [
{name: "Binary", base: 2, length: 8, top: 125},
{name: "Octal", base: 8, length: 3, top: 150, prefix: "\\"},
{name: "Octal", base: 8, length: 3, top: 150, prefix: "0o"},
{name: "Hexadecimal", base: 16, length: 2, top: 175, prefix: "0x"},
];

Expand Down Expand Up @@ -131,6 +131,8 @@ function drawNumeral({name, base, length, top, prefix}) {
result *= -1;
result ^= 0xFF;
++result;
// Force octal numbers to begin with 7
result |= (base === 8) ? 0o700 : 0;
}
}

Expand Down
5 changes: 5 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<html>
<head>
<title>Arithmetic</title>
<style>
canvas {
cursor: crosshair;
}
</style>
</head>
<body>
<canvas id="arithmetic" width="650" height="500">
Expand Down

0 comments on commit b088206

Please sign in to comment.