Formula to convert Hex to Decimal

Hello All,

I have "upgraded" from AppleWorks to iWork Numbers. Yes I've read all about how somethings didn't get ported over, etc. What I need is a formula to convert base 16 to base 10. Any ideas how to do this? I see that numbers has a formula editor so is it possible to make up a conversion formula? Someone done this who would like to share?

Thanks,
Dan

MacBook Pro, Mac OS X (10.5.5)

Posted on Nov 23, 2008 5:41 PM

Reply
5 replies

Nov 23, 2008 7:00 PM in response to Dan Spence1

Dan,

Here's a brute-force solution. There may be more elegant ones out there.

User uploaded file

DEC formula is: =IF(ISERROR(LOOKUP(MID(A2, 1, 1), LOOKUP TBL :: A$1:A$16, LOOKUP TBL :: B$1:B$16) * 16^3+LOOKUP(MID(A2, 2, 1), LOOKUP TBL :: A$1:A$16, LOOKUP TBL :: B$1:B$16) * 16^2+LOOKUP(MID(A2, 3, 1), LOOKUP TBL :: A$1:A$16, LOOKUP TBL :: B$1:B$16) * 16+LOOKUP(MID(A2, 4, 1), LOOKUP TBL :: A$1:A$16, LOOKUP TBL :: B$1:B$16)),"", LOOKUP(MID(A2, 1, 1), LOOKUP TBL :: A$1:A$16, LOOKUP TBL :: B$1:B$16) * 16^3+LOOKUP(MID(A2, 2, 1), LOOKUP TBL :: A$1:A$16, LOOKUP TBL :: B$1:B$16) * 16^2+LOOKUP(MID(A2, 3, 1), LOOKUP TBL :: A$1:A$16, LOOKUP TBL :: B$1:B$16) * 16+LOOKUP(MID(A2, 4, 1), LOOKUP TBL :: A$1:A$16, LOOKUP TBL :: B$1:B$16))

Be sure to Format Col A of both tables to Text.

Regards,

Jerry

Nov 24, 2008 2:54 AM in response to Dan Spence1

Storing the string 0123456789ABCDEF in A1,

If the decimal number is in column B,

=MID($A$1,1+INT(INT(B/16777216)/16),1)&MID($A$1,1+MOD(INT(B/16777216),16),1)&MID ($A$1,1+INT(INT(MOD(B,16777216)/65536)/16),1)&MID($A$1,1+MOD(INT(MOD(B,16777216) /65536),16),1)&MID($A$1,1+INT(INT(MOD(B,65536)/256)/16),1)&MID($A$1,1+MOD(INT(MO D(B,65536)/256),16),1)&MID($A$1,1+INT(MOD(B,256)/16),1)&MID($A$1,1+MOD(MOD(B,256 ),16),1)
converts it in hexadecimal.

If the hexadecimal number is in column C,

=IF(LEN($C)=8,((SEARCH(MID($C,1,1),$A$1)-1)*16+(SEARCH(MID($C,2,1),$A$1)-1))*256 ^3+((SEARCH(MID($C,3,1),$A$1)-1)*16+(SEARCH(MID($C,4,1),$A$1)-1))*256^2+((SEARCH (MID($C,5,1),$A$1)-1)*16+(SEARCH(MID($C,6,1),$A$1)-1))*256+(SEARCH(MID($C,7,1),$ A$1)-1)*16+(SEARCH(MID($C,8,1),$A$1)-1),123)
converts it in decimal.

Yvan KOENIG (from FRANCE lundi 24 novembre 2008 11:54:38)

Nov 24, 2008 8:04 PM in response to KOENIG Yvan

Thanks for the help but I'm still stuck. Ok, I get it that it is a lot harder to get Number to do things than it was in AppleWorks. I figured out how to make a table, easy. Yvan does your formula refer to the 0-F | 0-15 table? I copied your formula into my sheet and it didn't work. Then I made the table and it didn't work. Then I try replacing the $A$1 with a click in the table and it didn't work. What am I missing? I am working on converting incoming hex data into decimal.

Thanks,
Dan

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Formula to convert Hex to Decimal

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.