??? 07/19/12 10:33 Read: times |
#187958 - Please elaborate further. Responding to: ???'s previous message |
Are you dividing signed or unsigned numbers?
When dividing unsigned numbers, both division and right-shift will round towards zero. In order to round towards the nearest integer, add 0.5*divisor to the value to be divided, but beware of integer overflows. When dividing signed numbers, things get more interesting, since the division will still round towards zero ((-1/2) == 0), but the right-shift will round towards negative infinity ((-1>>1) == -1). |
Topic | Author | Date |
Right Shift Rounding Recommendations | 01/01/70 00:00 | |
add before shift | 01/01/70 00:00 | |
Guard digits? | 01/01/70 00:00 | |
How does this look? | 01/01/70 00:00 | |
Nice but.. | 01/01/70 00:00 | |
Please elaborate further. | 01/01/70 00:00 | |
01/01/70 00:00 | ||
I do not know how you managed, but | 01/01/70 00:00 | |
breaking the rules, one forum at a time . . . | 01/01/70 00:00 |