Bin2Dec allows the user to enter binary digits, 0's and 1's, and then displays its decimal equivalent, in any sequence and then displays its decimal equivalent.
- 💡 Features
- 🎯 Purpose
- 🛠 Installation
- 📝 Utilization
- 🤝 Contributing
- ⚙ Technologies Used
- 👋 Author
- 🧾 License
- ⇆ Convert a binary number to decimal
- 📋 Copy the result
My purpose with this project is how to do a binary number converter.
During this project I learned too:
- more about Javascript
- make a different UI
- how to copy a value from an element
You need to download git initially
Run this command to clone the repository:
git clone https://github.com/AleNoia/bin2dec.git
Start the index.html
file in the src
folder
It is a very simple to use Bin2Dec
// ======================================== [CONVERT FUNCTION]
this.convert = () => {
dec = 0
let bin = this.binSeletor.value
let test = /^[01]+$/g.test(bin);
// Conditional to accept only 0 and 1
if (!test) {
this.resSelector.value = "Enter only 1 or 0";
return;
}
try {
for (var i = 0; i < bin.length; i++) {
// CONVERT
dec = dec + parseInt(bin[i]) * Math.pow(2, bin.length - 1 - i);
}
} catch {
this.resSelector.value = "Error"
}
// PUTTING RESULTS IN THE DIV
this.resSelector.value = dec
}
// ======================================== [COPY]
this.copyResult = () => {
let copyValue = this.resSelector;
copyValue.select();
document.execCommand('copy');
}
Technologies that were used in the construction of the project:
- Fork the project.
- Create a new branch with your changes:
git checkout -b my-feature
- Save your changes and create a commit message telling you what you did:
git commit -m" feature: My new feature "
- Submit your changes:
git push origin my-feature
If you have any questions check this guide on how to contribute
Feel free to contribute 🙂
If you want to contact, mail me or send a message on Twitter
Released in 2021. This project is under the MIT license.
Made by Igor Noia 👋