From 7456f549c427008846b1c1362d7611af54f6c2e1 Mon Sep 17 00:00:00 2001
From: satya <92134652+Satyasn01@users.noreply.github.com>
Date: Tue, 15 Oct 2024 07:25:16 +0530
Subject: [PATCH] NOT btn added
---
index.html | 3 ++-
js/binaryCalculator.js | 16 ++++++++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/index.html b/index.html
index 67c2801..83ada83 100644
--- a/index.html
+++ b/index.html
@@ -86,13 +86,14 @@
+ |
|
|
|
- |
+ |
|
|
diff --git a/js/binaryCalculator.js b/js/binaryCalculator.js
index 784ea72..7466bf1 100644
--- a/js/binaryCalculator.js
+++ b/js/binaryCalculator.js
@@ -346,6 +346,22 @@ const rolButton = document.querySelector('input[value="ROL"]');
rorButton.addEventListener("click", () => circularShift('right'));
rolButton.addEventListener("click", () => circularShift('left'));
+function bitwiseNOT() {
+ let binaryInput = res.value;
+ let binaryInt = parseInt(binaryInput, 2);
+ if (!isNaN(binaryInt)) {
+ let numBits = binaryInput.length;
+
+ let invertedBinaryInt = ~binaryInt;
+ let mask = Math.pow(2, numBits) - 1;
+ let finalBinary = invertedBinaryInt & mask;
+
+ res.value = finalBinary.toString(2).padStart(numBits, '0');
+ } else {
+ res.value = "Invalid Input";
+ }
+}
+
function bitwiseAND() {
const input = document.form.textview.value.split(",");
if (input.length === 2) {