diff --git a/Calculators/Logical-MicroOperations-Calculator/README.md b/Calculators/Logical-MicroOperations-Calculator/README.md new file mode 100644 index 000000000..61f3439ed --- /dev/null +++ b/Calculators/Logical-MicroOperations-Calculator/README.md @@ -0,0 +1,17 @@ +#

Logical MicroOperations Calculator

+ +## Description :- + +- Solves logical micro-operations of Computer Architecture + +## Tech Stacks :- + +- HTML +- CSS +- JavaScript + +## Screenshots :- + +![image](../Logical-MicroOperations-Calculator/screenshot1.png) +![image](../Logical-MicroOperations-Calculator/screenshot2.png) +![image](../Logical-MicroOperations-Calculator/screenshot3.png) \ No newline at end of file diff --git a/Calculators/Logical-MicroOperations-Calculator/index.html b/Calculators/Logical-MicroOperations-Calculator/index.html new file mode 100644 index 000000000..97c9af1c2 --- /dev/null +++ b/Calculators/Logical-MicroOperations-Calculator/index.html @@ -0,0 +1,46 @@ + + + + + + + + + Logical Micro-Options Calculator + + + +
+

Logical Micro-Options Calculator

+ + + +
+ + + + + + + + + + + + + + + + + +
+ +
+

Result:

+

+
+
+ + + + diff --git a/Calculators/Logical-MicroOperations-Calculator/screenshot1.png b/Calculators/Logical-MicroOperations-Calculator/screenshot1.png new file mode 100644 index 000000000..b0bed730a Binary files /dev/null and b/Calculators/Logical-MicroOperations-Calculator/screenshot1.png differ diff --git a/Calculators/Logical-MicroOperations-Calculator/screenshot2.png b/Calculators/Logical-MicroOperations-Calculator/screenshot2.png new file mode 100644 index 000000000..41d474cbf Binary files /dev/null and b/Calculators/Logical-MicroOperations-Calculator/screenshot2.png differ diff --git a/Calculators/Logical-MicroOperations-Calculator/screenshot3.png b/Calculators/Logical-MicroOperations-Calculator/screenshot3.png new file mode 100644 index 000000000..12a2c1e8f Binary files /dev/null and b/Calculators/Logical-MicroOperations-Calculator/screenshot3.png differ diff --git a/Calculators/Logical-MicroOperations-Calculator/script.js b/Calculators/Logical-MicroOperations-Calculator/script.js new file mode 100644 index 000000000..d08767898 --- /dev/null +++ b/Calculators/Logical-MicroOperations-Calculator/script.js @@ -0,0 +1,117 @@ +function validateInputs() { // Function to check if the input is valid or not + const binary1 = document.getElementById('binary1').value; + const binary2 = document.getElementById('binary2').value; + const errorElement = document.getElementById('error'); + errorElement.innerText = ''; + + const binaryPattern = /^[01]+$/; // regex to verify binary number + + if (!binary1 || !binary2) { + errorElement.innerText = 'Both fields must be filled in.'; + return false; + } + + if (!binaryPattern.test(binary1) || !binaryPattern.test(binary2)) { + document.getElementById('result').innerText = ''; + errorElement.innerText = 'Please enter valid binary numbers (0 or 1).'; + return false; + } + + return true; +} + +function selectiveSet() { // selective set operation logic + if (!validateInputs()) return; + + const binary1 = document.getElementById('binary1').value; + const binary2 = document.getElementById('binary2').value; + const result = (parseInt(binary1, 2) | parseInt(binary2, 2)).toString(2).padStart(binary1.length, '0'); + document.getElementById('result').innerText = result; +} + +function selectiveComplement() { // selective complement operation logic + if (!validateInputs()) return; + + const binary1 = document.getElementById('binary1').value; + const binary2 = document.getElementById('binary2').value; + const result = (parseInt(binary1, 2) ^ parseInt(binary2, 2)).toString(2).padStart(binary1.length, '0'); + document.getElementById('result').innerText = result; +} + +function selectiveClear() { // selective clear operation logic + if (!validateInputs()) return; + + const binary1 = document.getElementById('binary1').value; + const binary2 = document.getElementById('binary2').value; + const result = (parseInt(binary1, 2) & ~parseInt(binary2, 2)).toString(2).padStart(binary1.length, '0'); + document.getElementById('result').innerText = result; +} + +function maskDelete() { // mask operation logic + if (!validateInputs()) return; + + const binary1 = document.getElementById('binary1').value; + const binary2 = document.getElementById('binary2').value; + + let result = ''; + for (let i = 0; i < binary1.length; i++) { + if (binary2[i] === '0') { + result += '0'; + } else { + result += binary1[i]; + } + } + + document.getElementById('result').innerText = result; +} + +function clearBits() { // Clear bits operation logic + if (!validateInputs()) return; + + const binary1 = document.getElementById('binary1').value; + const binary2 = document.getElementById('binary2').value; + + let result = ''; + for (let i = 0; i < binary1.length; i++) { + if (binary1[i] === binary2[i]) { + result += '0'; + } else { + result += '1'; + } + } + + document.getElementById('result').innerText = result; +} + +function insert() { // insert operations logic + if (!validateInputs()) return; + + const binary1 = document.getElementById('binary1').value; + const binary2 = document.getElementById('binary2').value; + + // Create a mask to clear the desired bit positions in binary1 + const mask = parseInt('1'.repeat(binary1.length - binary2.length) + '0'.repeat(binary2.length), 2); + const maskedBinary1 = (parseInt(binary1, 2) & mask).toString(2).padStart(binary1.length, '0'); + + // Perform an OR operation to introduce the new bits from binary2 + const result = (parseInt(maskedBinary1, 2) | parseInt(binary2, 2)).toString(2).padStart(binary1.length, '0'); + + document.getElementById('result').innerText = result; +} + + +function compare() { // compare operations logic + if (!validateInputs()) return; + + const binary1 = document.getElementById('binary1').value; + const binary2 = document.getElementById('binary2').value; + const result = binary1 === binary2 ? 'Equal' : 'Not Equal'; + document.getElementById('result').innerText = result; +} + +function clearInputs() { // clearing all input fields + document.getElementById('binary1').value = ''; + document.getElementById('binary2').value = ''; + document.getElementById('result').innerText = ''; + document.getElementById('error').innerText = ''; +} \ No newline at end of file diff --git a/Calculators/Logical-MicroOperations-Calculator/style.css b/Calculators/Logical-MicroOperations-Calculator/style.css new file mode 100644 index 000000000..1529da971 --- /dev/null +++ b/Calculators/Logical-MicroOperations-Calculator/style.css @@ -0,0 +1,100 @@ +body { + font-family: 'Roboto', Arial, sans-serif; + display: flex; + justify-content: center; + align-items: center; + height: 100vh; + margin: 0; + background: linear-gradient(135deg, #89f7fe, #66a6ff); +} + +.calculator { + background-color: #ffffff; + padding: 25px; + border-radius: 12px; + box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1); + text-align: center; + width: 100%; + max-width: 500px; + transition: transform 0.3s ease-in-out; +} + +.calculator:hover { + transform: scale(1.02); +} + +input { + width: 100%; + padding: 12px 15px; + margin: 10px 0; + border-radius: 8px; + border: 1px solid #ccc; + font-size: 1em; + box-sizing: border-box; + transition: border-color 0.3s ease-in-out; +} + +input:focus { + outline: none; + border-color: #007bff; +} + +.button-group { + margin-top: 15px; + display: flex; + flex-wrap: wrap; + justify-content: space-between; +} + +.button-group button { + flex: 1 1 calc(50% - 10px); + margin: 5px; + padding: 12px 10px; + border-radius: 8px; + border: none; + background-color: #007bff; + color: white; + font-size: 1em; + cursor: pointer; + transition: background-color 0.3s ease-in-out, transform 0.3s ease-in-out; + box-sizing: border-box; +} + +.button-group button:hover { + background-color: #0057b3e0; + transform: translateY(-2px); +} + +.button-group button:nth-child(8):hover{ + background-color: rgba(246, 66, 66, 0.904); + transform: translateY(-2px); +} + +.result { + margin-top: 25px; + font-size: 1.3em; + font-weight: bold; + color: #333; +} + +#error { + margin-top: 15px; + color: #ff4d4f; + font-weight: bold; +} + +/* Responsiveness */ +@media (max-width: 500px) { + .calculator { + padding: 20px; + } + + .button-group button { + padding: 10px 8px; + font-size: 0.9em; + } + + .result { + font-size: 1.2em; + } +} diff --git a/index.html b/index.html index 8403d9e28..f52db3d78 100644 --- a/index.html +++ b/index.html @@ -3155,6 +3155,20 @@

Calculates the log of the given number to any base.

+
+
+

Logical Micro-Operations Calculator

+

Solves logical micro-operations of Computer Architecture

+ +
+

Lorentz Force Calculator

@@ -4976,6 +4990,20 @@

Checks whether a number is a strong number or not.

+
+
+

Sudoku Calculator

+

Generates and solves sudoku

+ +
+

Sugar Intake Calculator