
24 bit signed number conversion
Without seeing what you're doing now it's a little difficult to know what
you need to add, but if what you're doing is converting the decimal value to
a string of 1's and 0's, then all you need to do is cast the value into the
32-bit number space (a long integer) and mask off the upper 8 bits. This
will turn it into an unsigned (technically, positive) value having the same
bit pattern as the signed 24-bit value. This works whether the value is
negative or positive:
MyVal& = (CLng(My24bits) And &HFFFFFF) 'unsigned' long
Then just convert the lower 24 bits of that value to a binary string.
Ignore what the value appears to be... the bit pattern is the same and
that's all that matters.
--
Jim Mack
MicroDexterity, Inc
http://www.microdexterity.com
Quote:
>I have written code to convert a decimal value to a signed 24 bit binary
>value (+/- 8,388,608 bin), the only problem is I am having problems
>doing it for negative values.
>Any suggestions, thanks in advance