Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Speed of certain operations

Author: David Blackman

Date: 00:13:08 06/17/99

Go up one level in this thread


On June 16, 1999 at 23:01:38, Dave Gomboc wrote:

>On June 16, 1999 at 22:56:02, Greg Lazarou wrote:
>
>>Hi James,
>>
>>I don't have the straight answer to your question but if x is an integer then
>>multiplications by 2 and divisions by 2 (the 4th and 2nd cases respectively)
>>should be very fast left and right shifts. Now you can let the compiler figure
>>it out (and you may be able to help the compiler figure it out by expressing
>>x*=.5 as x /= 2) or you can code it as a shift yourself...
>
>N.B. (x /= 2) == (x >> 1) iff (x is unsigned)
>
>Dave

But for signed numbers (x >> 1) is almost always what you really want. And if
you want to divide by something other than a power of two you curse hardware and
language designers for not making signed division work properly.



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.