Convert Hexadecimal To Decimal
Write a program to convert hexadecimal to decimal
Hexadecimal is a base-16 number system. It uses sixteen digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F. The digits are called hexits. A hexit is the smallest unit of information in a computer. A hexit can be used to represent a single value, such as 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, or F, or it can be used to represent a single state, such as on or off.
To convert a hexadecimal number to decimal, we can use the following algorithm:
- Multiply the first hexit by 16^0.
- Multiply the second hexit by 16^1.
- Multiply the third hexit by 16^2.
- Multiply the fourth hexit by 16^3.
- Repeat steps 3 and 4 until the last hexit.
- Add the results of all the multiplications.
- The decimal number is the sum of all the multiplications.
Input : A Output : 10
Become a Sponsor![Heart with ribbon](/_next/image?url=%2Fheart-with-ribbon.png&w=48&q=75)
Become a sponsor and help us maintain and improve this project. Every contribution counts. Thank you!
GitHub Sponsors