Author: martin fierz
Date: 04:37:40 12/04/04
Go up one level in this thread
On December 03, 2004 at 16:24:45, Dieter Buerssner wrote: >On December 03, 2004 at 16:09:43, martin fierz wrote: > >>i have always found & to be a surprisingly large amount faster than %, even when >>using #defined power-of-2-constants. > >Hmmm - can you show an example? (just a code snippet) hi dieter, i remember now where i saw a big difference. as long as i do something like #define HASHSIZE 1<<N then i see no difference in index = key % HASHSIZE and index = key & (HASHSIZE-1). but in my programs, the hashsize is flexible, so i have something like int hashsize = HASHSIZE // initialize to default value, and then the above with hashsize as variable. there the compiler cannot optimize the % away. so i have to do the & thing. come to think of it, could i have used index = key % (1<<loghashsize) ? would that be optimized? cheers martin
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.