Jump to content

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

Recommended Posts

Posted

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

Version: v6.x

Platform: Mac OS 9

Posted

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.

Posted

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

bitbanger... i love it :-)

  • 3 weeks later...
Posted

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?

Posted

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.

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.