hex2dec

T

twilkers

I need to convert a list of 16 bit hex values to decimal. The list contains
both positive and negative numbers.

hex2dec works for a 10 digit but for anything less the number appears to be
padded with zeros and doesn't come out negative as it should. Example,
0xFFE6 comes out 65510 instead of -26(correct)

Is there a fix for this? The list is very long.

thanks,
tim
 
J

JoeU2004

twilkers said:
hex2dec works for a 10 digit but for anything less the number appears to
be
padded with zeros and doesn't come out negative as it should. Example,
0xFFE6 comes out 65510 instead of -26(correct)

One way:

=HEX2DEC(A1) - 65536*AND(LEN(A1)=4,HEX2DEC(LEFT(A1,1))>=8)


----- original message -----
 
J

JoeU2004

PS....

More straight-forward:

=HEX2DEC(A1) - 65536*(HEX2DEC(A1)>32767)


----- original message -----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top