POV-Ray : Newsgroups : povray.off-topic : Games programmers : Re: Games programmers Server Time
10 Oct 2024 17:17:48 EDT (-0400)
  Re: Games programmers  
From: Vincent Le Chevalier
Date: 12 Sep 2008 15:14:21
Message: <48cabf8d$1@news.povray.org>
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.

-- 
Vincent


Post a reply to this message

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