Skip to content

Commit

Permalink
Finally really corrected AND operator
Browse files Browse the repository at this point in the history
  • Loading branch information
Coffee-for-Cats committed Oct 17, 2024
1 parent 03a3369 commit 923f577
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/interpreter.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,17 @@ function AND_OP(number1, number2) {
const binary1 = int1.toString(2).padStart(16, '0')
const binary2 = int2.toString(2).padStart(16, '0')

let returning = false
for(let i = 0; i < 8; i++) {
if(binary1[i] === '1') {
if(binary2[i] === '1') returning = true;
else returning = false;
let returning = false;
for(let i = 0; i < binary1.length; i++) {
console.log(binary1[i], binary2[i])
if(binary1[i] == '1') {
if(binary2[i] == '1') {
returning = true;
} else returning = false;
}
}

console.log(binary1, binary2, returning)

return returning;
}

0 comments on commit 923f577

Please sign in to comment.