Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
Per Westermark
07/16/12 11:12
Read: 496 times
Sweden


 
#187953 - add before shift
Responding to: ???'s previous message
Add 0.5 to the number before shifting. Obviously not the floating point value 0.5, but the integer representing 0.5 in your fixed-point notation.

So if you are going to shift right 1 time, you add 1.
If you are going to shift right 2 times, you add 2.
If you are going to shift right 3 times, you add 4.

Obviously, you have to make sure that the addition before the shift doesn't result in an overflow.


List of 9 messages in thread
TopicAuthorDate
Right Shift Rounding Recommendations      Jeremy Brookley      07/16/12 10:30      
   add before shift      Per Westermark      07/16/12 11:12      
   Guard digits?      Oliver Sedlacek      07/16/12 22:25      
      How does this look?      Jeremy Brookley      07/17/12 05:21      
         Nice but..      Oliver Sedlacek      07/18/12 09:55      
   Please elaborate further.      Christoph Franck      07/19/12 04:33      
             Jeremy Brookley      07/19/12 10:02      
      I do not know how you managed, but      Erik Malund      07/19/12 12:48      
         breaking the rules, one forum at a time . . .      Jeremy Brookley      07/19/12 13:59      

Back to Subject List