converting 24 bit hex values

R

RG

I am reading from my serial port a 24 bit hex number which consists of
6 place values.
For example:
7FED6F which equals 8383855 using the hex2dec excel function.
I need to convert this hex into a value I can display in a textbox and
also do other math functions with.

I looked at the example of i = Convert.ToUInt32(buffer1,16) but my
number is 1 24 bit number, not 16. How can I convert into a useable 24
bit number?

Thanks
 
M

Michael C

RG said:
I am reading from my serial port a 24 bit hex number which consists of
6 place values.
For example:
7FED6F which equals 8383855 using the hex2dec excel function.
I need to convert this hex into a value I can display in a textbox and
also do other math functions with.

I looked at the example of i = Convert.ToUInt32(buffer1,16) but my
number is 1 24 bit number, not 16. How can I convert into a useable 24
bit number?

The FromBase parameter is the base of the number, not the number of bits.
Because this is a hex number 16 is correct. It should work fine because
UInt32 is obviously a 32bit number and you have only 24. Because we don't
have a 24bit datatype in dot net the best match is 32bit.

Michael
 

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