# hex conversion

This topic is 6495 days old. Please don't post here. Open a new topic instead.

## Recommended Posts

Does anyone know an easy calc formula to convert decimal into hex numbers?

Version: v6.x

Platform: Mac OS 9

##### Share on other sites

Here is a FMI tech article that may help.

Lee

##### Share on other sites

This will work for up to 32 bit numbers. And I came up with it before I read the tech article... Sometimes being an old bit-banger actually helps! This version is the instructional version, substitute the actual 2^x numbers to make it execute faster.

Middle("0123456789ABCDEF", Mod( Int(theInteger / 2^28), 2^4) + 1, 1) &

Middle("0123456789ABCDEF", Mod( Int(theInteger / 2^24), 2^4) + 1, 1) &

Middle("0123456789ABCDEF", Mod( Int(theInteger / 2^20), 2^4) + 1, 1) &

Middle("0123456789ABCDEF", Mod( Int(theInteger / 2^16), 2^4) + 1, 1) &

Middle("0123456789ABCDEF", Mod( Int(theInteger / 2^12), 2^4) + 1, 1) &

Middle("0123456789ABCDEF", Mod( Int(theInteger / 2^8), 2^4) + 1, 1) &

Middle("0123456789ABCDEF", Mod( Int(theInteger / 2^4), 2^4) + 1, 1) &

Middle("0123456789ABCDEF", Mod( theInteger, 2^4) + 1, 1)

For those who don't know: a bit-banger is someone who worked on computers with front panel switches and lights (for each bit). The switches allowed data and instructions to be entered and the processor to be stopped, started, and single stepped through instructions. Many were the hours spent debugging operating systems & hardware... Fond memories of my Data General Nova and Teletype ASR-33.

##### Share on other sites

just what the doctor ordered - thank you! i'll take a look at the teech articel also.

bitbanger... i love it :-)

##### Share on other sites

• 3 weeks later...

i thought i could just reverse the logic to make decimals from hex numbers. seems to be more involved. is there another formula that can do it or would i need to script it to convert one digit at a time?

##### Share on other sites

This will give you the decimal value of a hex number that's up to 8 digits long:

((((((((

(Position("0123456789ABCDEF",Middle(Right("00000000"&TheHexNumber,8),1,1),1,1 )-1))*16+

(Position("0123456789ABCDEF",Middle(Right("00000000"&TheHexNumber,8),2,1),1,1 )-1))*16+

(Position("0123456789ABCDEF",Middle(Right("00000000"&TheHexNumber,8),3,1),1,1 )-1))*16+

(Position("0123456789ABCDEF",Middle(Right("00000000"&TheHexNumber,8),4,1),1,1 )-1))*16+

(Position("0123456789ABCDEF",Middle(Right("00000000"&TheHexNumber,8),5,1),1,1 )-1))*16+

(Position("0123456789ABCDEF",Middle(Right("00000000"&TheHexNumber,8),6,1),1,1 )-1))*16+

(Position("0123456789ABCDEF",Middle(Right("00000000"&TheHexNumber,8),7,1),1,1 )-1))*16+

(Position("0123456789ABCDEF",Middle(Right("00000000"&TheHexNumber,8),8,1),1,1 )-1))

The field "TheHexNumber" must be text.

##### Share on other sites

i wouldn't have come up with this in a million years! thanks much!

##### Share on other sites

This topic is 6495 days old. Please don't post here. Open a new topic instead.

## Create an account

Register a new account