• Register now to get access to thousands of Tutorials, Leaked content, Hot NSFW and much more. Join us as we build and grow the community.

Advertise Here

Advertise Here

Advertise Here

How to Create Converter for Binary to Decimal

kikecoxon133

AI Systems Architect
K Rep
0
0
0
Rep
0
K Vouches
0
0
0
Vouches
0
Posts
61
Likes
125
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 2 1000 XP
If you are looking for a simple Converter For Binary To Decimal then you are at the right place. This converter works by entering a desired numeric value from the user then the user clicks the "Ok" button to convert the Binary Value to in Decimal Form.

This program creates using JavaScript.

You can also check the live demo of this simple tutorial, so you can get an idea and you can try this out, let's start coding.

⚙ Live Demo

JavaScript Source Code

This script will ask the user to input the numerical value to convert binary to decimal.

  1. <

    script>
  2. function

    binaryConvert_toDecimal(

    binary_Value )

    {
  3. var

    decimalNumber =

    0

    ;
  4. var

    placeValue =

    1

    ;

  5. while (

    binary_Value >

    0

    )

    {

  6. var

    remainder =

    binary_Value %

    10

    ;
  7. var

    digitValue =

    remainder *

    placeValue;
  8. decimalNumber =

    decimalNumber +

    digitValue;
  9. placeValue *=

    2

    ;

  10. binary_Value =

    Math

    .floor

    (

    binary_Value /

    10

    )

    ;
  11. }
  12. return

    decimalNumber;
  13. }

  14. var

    input =

    parseInt(

    prompt(

    "Enter your desired value."

    )

    )

    ;

  15. input_solve =

    binaryConvert_toDecimal(

    input)

    ;

  16. if

    (

    !

    isNaN(

    input)

    )

    {
  17. document.write

    (

    "<h2><b style='color:red;'>"

    +

    input +

    "<sub>2</sub></b> in binary is equivalent to <b style='color:blue;'>"
  18. +

    input_solve +

    "<sub>10</sub></b> in decimal. </h2>"

    )

    ;
  19. }
  20. while(

    isNaN(

    input)

    )

    {
  21. input =

    parseInt(

    prompt(

    "Please enter a numerical value."

    )

    )

    ;

  22. input_solve =

    binaryConvert_toDecimal(

    input)

    ;

  23. if

    (

    !

    isNaN(

    input)

    )

    {
  24. document.write

    (

    "<h2><b style='color:red;'>"

    +

    input +

    "<sub>2</sub></b> in binary is equivalent to <b style='color:red;'>"
  25. +

    input_solve +

    "<sub>10</sub></b> in decimal.</h2>"

    )

    ;
  26. }
  27. }
  28. </

    script>

Output:

Where the user types the value of binary to convert into decimal.

1_65.jpg


This is the output after the user types the numerical value.

2_34.jpg


⚙ Live Demo

For the full source code, kindly click the "Download Code" button below.

If you are interested in programming, we have an example of programs that may help you even just in small ways.

So what can you say about this work? Share your thoughts in the comment section below or email me at [email protected]. Practice Coding. Thank you very much.


Download
You must upgrade your account or reply in the thread to view the hidden content.
 

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

452,501

351,446

351,460

Top