From: Christopher Phillips (shrydar_at_jaruth.com)
Date: 2004-12-11 19:38:40
On 12 Dec 2004, at 01:50, Craig T. Taylor wrote: >> > > Actually, tmp=(new-old)/2 is better. (Really, tmp=(new-old)>>1 if the > compiler has a crappy optimizer). It's best to loose precision at the > end of an expression rather than midstream. The revised formula will > feel more responsive to relative changes while the new/2 - old/2 would > be okay for boundary changes. > tmp=(new-old)/2 has exactly the same bug that I was trying to avoid by doing the division - by the time you've divided by two you've already overflowed. (btw, I should really have written tmp=(signed)(new/2)-(signed)(old/2), or (to take your parenthetical advice), tmp=(signed)(new>>1)-(signed)(old>>1); ) Message was sent through the cbm-hackers mailing list
Archive generated by hypermail pre-2.1.8.