Author: Sune Fischer
Date: 04:02:54 11/19/02
Go up one level in this thread
On November 19, 2002 at 06:36:08, Gerd Isenberg wrote:
>On November 19, 2002 at 05:28:03, Sune Fischer wrote:
>
>>On November 19, 2002 at 04:57:50, Gerd Isenberg wrote:
>>>Therefore it is often possible to replace some conditional assignments or simple
>>>if[else] statements by some cheap test,cmp,setcc,shift,add or lea instructions:
>>>
>>>c = a > b ? 32 : 16;
>>>c = 16 + 16*(a>b);
>>
>>is that legal, will a>b (true or false) always be 1 or 0?
>
>Yes, boolean expressions with relational and/or logical operators produce a
>[0,1] result.
>
>>
>>Because usually expressions like:
>>if (x) {...}
>>just means x!=0.
>>
>
>If you write (x != 0) the boolean result is [0,1].
ok.
But is this different from ((bool)x)?
Is (bool)x just 1&x or does it do x!=0, which is not the same of course.
Last question, does it matter if x is negative, will (-1) be false?
I always get warnings when casting to boolean, I never get warnings usually when
casting, in fact I cast to get rid of those warnings, so something must be going
on.
>>>// color [0,1] ==> white,black
>>>delta = color == WHITE ? 8 : -8;
>>
>>how about:
>>
>>delta = -8*(((color)<<1)-1)
>
>should procuce the same code as
>
>delta = 8 - 16*color;
>or
>delta = 8*(1 - 2*color);
Yeah, you are right I got it now, you were making a point, sorry :)
-S.
>Gerd
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.