Can someone please help me write a convertor for Hexidecimal to Decimal, has anyone found a way to allow for the entries to be able to be multiplied as integers, even if the input is a character and not a natural number.

Thanks Jack

Jacktheclimber 0 Newbie Poster

Can someone please help me write a convertor for Hexidecimal to Decimal, has anyone found a way to allow for the entries to be able to be multiplied as integers, even if the input is a character and not a natural number.

Thanks Jack

ddanbe 2,724 Professional Procrastinator Featured Poster

If the input is a 9 chararcter, then digit to convert is equal to 9.

If the input is a A chararcter, then digit to convert is equal to 10.

If the input is a B chararcter, then digit to convert is equal to 11.

....

Santanu.Das 125 Santanu Das

http://home.iitj.ac.in/~ramana/pds/number_systems.pdf

http://www.cs.ucf.edu/courses/cop3502h.02/binay_octal_Hex.pdf

http://www.math-only-math.com/conversion-of-binary-numbers-to-octal-or-hexa-decimal-numbers.html

http://www.rapidtables.com/math/number/Numeral_system.htm

http://math.stackexchange.com/questions/541253/hexadecimal-to-octal-and-vice-versa

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Python function int() will do this for you ...

```
hx = "FFFF"
# convert hexadecimal string hx to a denary (base 10) number
n = int(hx, 16)
print(n) # 65535
```

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Math with hexadecimal numbers ...

```
hx1 = "FF"
hx2 = "B7"
product = int(hx1, 16) * int(hx2, 16)
print("{} * {} = {} --> {:X}".format(hx1, hx2, product, product))
'''
FF * B7 = 46665 --> B649
'''
```

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.