:: Re: [DNG] [OT] [Re: Studying C as t…
Góra strony
Delete this message
Reply to this message
Autor: Simon Walter
Data:  
Dla: dng
Temat: Re: [DNG] [OT] [Re: Studying C as told. (For help)


On 06/21/2016 05:28 PM, KatolaZ wrote:
> On Tue, Jun 21, 2016 at 08:22:41AM +0200, Edward Bartolo wrote:
>
> [cut]
>
>>
>> I studied 'and' and 'or' boolean operators back when I studied Delphi
>> Pascal. I am embarrassed to have written such a stupid thing. It must
>> be due to the fact I wrote the email just before going to bed.
>>
>> AND: requires ALL sub-expressions to be true to evaluate to true
>> i.e.   Q = A ^ B ^ C ^ .... D
>>          Q = 1 if and only if A = B = C = .... D = 1

>>
>> OR: only requires ONE sub-exression to be true to evaluate to true
>> i.e.   Q = A v B v C v .... D
>>          Q = 1 if any Ai = 1

>>
>> These properties are used by compilers to optimize on boolean
>> expression evaluation. If I remember well, there are also specific
>
> Be careful, because conditional expressions in C are subject to
> "short-circuiting", meaning that only the minimum number of
> expressions sufficient to determine the value of a chain of && and ||
> will be evaluated. In particular, a chain of || expressions will be
> evaluated until there is one that evaluates to TRUE (!=0), while a
> chain of && is evaluated until there is one of them which evaluates to
> false (==0).
>


Isn't that how AND and OR work in most programming languages? Mind you,
I am not familiar with that many.