POV-Ray : Newsgroups : povray.off-topic : Games programmers : Re: Games programmers Server Time
10 Oct 2024 17:20:58 EDT (-0400)
  Re: Games programmers  
From: andrel
Date: 12 Sep 2008 15:59:01
Message: <48CACA4C.4020300@hotmail.com>
On 12-Sep-08 21:14, Vincent Le Chevalier wrote:
> andrel a écrit :
>>>>> Which one is FALSE? Is that 0 or 1? I know it's one or the other, 
>>>>> but I can never ever remember which - and it's kind of important!
>>>>
>>>> 0. Any other value is true.
>>>
>>> I remember that 0 is one thing and everything else is the opposite. 
>>> But I can never remember which is which.
>>
>> It's easy, booleans are a sort of integers following the normal 
>> convention that 0 is false and 1 is true. That any other value also 
>> works comes from the fact that most processors have a zero flag that 
>> you can conditionally jump on. Another example of hardware influencing 
>> the language.
> 
> There is also a similarity between the behaviours of positive integers, 
> multiplication and addition, and booleans, AND and OR. That is:
> 
>  Integers            Booleans
> a*(b+c) = a*b + a*c        a AND (b OR c) = (a AND b) OR (a AND c)
> 0 + a = a            false OR a = a
> 0 * a = 0            false AND a = false
> if a>0, a+b>0 for all b        if a is true, a OR b is true for all b
> And so on...
> 
> It does not work out that well if you set true <-> 0.
> 
If you take
   true <-> 0
   false <-> 1
   OR <-> *
   AND <-> +
it works again.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.