× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



 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 thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 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.