项目作者: AleNoia

项目描述 :
Binary-to-Decimal number converter implemented with JavasScript
高级语言: SCSS
项目地址: git://github.com/AleNoia/bin2dec.git
创建时间: 2021-05-23T19:40:54Z
项目社区:https://github.com/AleNoia/bin2dec

开源协议:MIT License

下载



👨‍💻 Bin2dec


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.


GitHub language count Repository size License GitHub last commit


image


📌 Table of Contents


💡 Features" class="reference-link">💡 Features

  • ⇆ Convert a binary number to decimal
  • 📋 Copy the result

🎯 Purpose" class="reference-link">🎯 Purpose

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

🛠 Installation" class="reference-link">🛠 Installation

You need to download git initially

Run this command to clone the repository:

  1. git clone https://github.com/AleNoia/bin2dec.git

🎲 Runnig

Start the index.html file in the src folder


📝 Utilization" class="reference-link">📝 Utilization

It is a very simple to use Bin2Dec

1. Insert the binary number into the first input

2. Click the convert button

  1. // ======================================== [CONVERT FUNCTION]
  2. this.convert = () => {
  3. dec = 0
  4. let bin = this.binSeletor.value
  5. let test = /^[01]+$/g.test(bin);
  6. // Conditional to accept only 0 and 1
  7. if (!test) {
  8. this.resSelector.value = "Enter only 1 or 0";
  9. return;
  10. }
  11. try {
  12. for (var i = 0; i < bin.length; i++) {
  13. // CONVERT
  14. dec = dec + parseInt(bin[i]) * Math.pow(2, bin.length - 1 - i);
  15. }
  16. } catch {
  17. this.resSelector.value = "Error"
  18. }
  19. // PUTTING RESULTS IN THE DIV
  20. this.resSelector.value = dec
  21. }

3. The result will come out in the second input

4. You can copy the result

image

  1. // ======================================== [COPY]
  2. this.copyResult = () => {
  3. let copyValue = this.resSelector;
  4. copyValue.select();
  5. document.execCommand('copy');
  6. }

⚙ Technologies used" class="reference-link"> ⚙ Technologies used

Technologies that were used in the construction of the project:


🤝 Contributing" class="reference-link">🤝 Contributing

  1. Fork the project.
  2. Create a new branch with your changes: git checkout -b my-feature
  3. Save your changes and create a commit message telling you what you did: git commit -m" feature: My new feature "
  4. Submit your changes: git push origin my-feature

If you have any questions check this guide on how to contribute

Feel free to contribute 🙂


👋 Author" class="reference-link">👋 Author

Igor Noia Silva

If you want to contact, mail me or send a message on Twitter

Gmail Badge badge


🧾 License" class="reference-link">🧾 License

Released in 2021. This project is under the MIT license.

Made by Igor Noia 👋