|
Ok,
<snip>
I'm not sure where the sign bit is in both cases.
</snip>
After a little more digging it would appear that the sign bit is ALWAYS the
leftmost bit. So I think I will have to perform the following:
// Derive sector size...
integerOut = integerIn;
if integerOut_1 < 128;
integerOut = (integerOut_1) + (integerOut_2 * (2**8)) +
(integerOut_3 * (2**16)) + (integerOut_4 * (2**24));
else;
integerOut_1 -= 128;
integerOut = -((integerOut_1) + (integerOut_2 * (2**8)) +
(integerOut_3 * (2**16)) + (integerOut_4 * (2**24)))
endif;
return integerOut;
This code now checks whether the first byte is greater than 128 (leftmost
bit is 1). If so, the whole number is negative. This means I must subtract
128 from the unsigned number representing the leftmoost byte, and then make
the result negative. Otherwise I let the calculation carry on as before.
Does that make sense?
Cheers
Larry Ducie
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.