Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Bizar Question for programmers: very strange behaviour of my engine

Author: Chan Rasjid

Date: 00:29:48 01/18/06

Go up one level in this thread


On January 17, 2006 at 17:41:03, James Swafford wrote:

>On January 17, 2006 at 14:59:15, Robert Hyatt wrote:
>
>>On January 17, 2006 at 12:52:40, James Swafford wrote:
>>
>>>On January 17, 2006 at 12:29:21, JW de Kort wrote:
>>>
>>>>Thank you for your reply. I check the boundries of the array's but that seems to
>>>>be correct.
>>>>
>>>>Could you please clarify your response because i'am not 100% sure what you mean.
>>>>
>>>
>>>I'll try.  Let me preface this with this caveat: I doubt this is
>>>your problem. :)  Dann's advice is pretty sound.
>>>
>>>Let's say you are evaluating a bitwise expression "a & b".
>>>If a == 0, then ( a & b ) == 0 for any b.  So, it's not
>>>necessary for the compiler to go to the trouble of figuring
>>>out what b is.
>>>
>>>In your case, a & b represent items in an array.  What is
>>>really evaluated is probably implementation specific
>>>(depends on the compiler), but it wouldn't even need to fetch
>>>the item from the second array to do the bitwise comparison
>>>if your first item (a) is 0.  So, possibly you are skirting a
>>>boundary bug when i==1 since your "a" is always 0.
>>>
>>>Again, I doubt that's the case in your program, but it's
>>>a possiblity.
>>>
>>>--
>>>James
>>>
>>
>>I don't see how that would cause a problem, since it has to fetch both values,
>>and then AND them to produce the final zero/non-zero result for testing.  This
>>isn't the same as
>
>
>
>Why does it have to?  If you say that's what most compilers *do*, then
>I believe you (I don't claim to be a compiler expert), but, mathematically,
>they don't *have to*, since  0 & b == 0 for any integer b.
>Please tell me what I'm missing. :)
>James

I can guess compiler has to have a natural degree of dumbness.
You specifically ask to test if ( (a & b)== 0 ).

I doubt they do extra work to add if (a == 0), ..or if (a == 0) && if (b == 0 ).
Rather the expected method is fetch, a, fetch b AND them and test.

Rasjid














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.