Author: Paul Byrne
Date: 21:10:00 12/14/01
Not sure if it is the compiler that is stupid or the question... :)
When I started using the MS compiler recently I discovered that rand()
is only 16 bits & just hacked this together to get things running...
[yes, I know rand() is evil, but ignore that for a moment :)]
unsigned rand32()
{
return (unsigned) (rand() ^ (rand()<<7) ^ (rand()>>7) ^
(rand()<<17) ^ (rand()>>17) ^ (rand()<<23) ^ (rand()>>23));
}
Problem is, this returns different things in debug and release mode,
which stops my opening books from functioning in debug mode.
rand() is returning the same sequence of integers, so I'm assuming
the optimizer is messing with the order of the calls (I'm just using
the default maximize speed settings).
Shouldn't the ^ operator always be left to right?
Am I missing something here, or is the compiler breaking the rules? :)
Thanks
-paul
This page took 0.01 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.