
-----------------------------------
Jimbo1991
Tue May 27, 2008 10:05 am

what is a boolean
-----------------------------------
what exactly is a boolean?

-----------------------------------
SNIPERDUDE
Tue May 27, 2008 10:09 am

RE:what is a boolean
-----------------------------------
a boolean is a type of variable.

an integer (int) holds a whole number
a real number (real) hold a decimal number
a boolean hold a true/false value.

ex:
var test : boolean := true

-----------------------------------
isaiahk9
Tue May 27, 2008 3:18 pm

RE:what is a boolean
-----------------------------------
Booleans are useful when you only deal with two possible outcomes.
Example - 
var isp1right : boolean := true
loop
if player clicks left key, then isp1right := false, p1x -= 5
elsif player clicks right key, then isp1right := true, p1x += 5
end if
Draw (character, p1x, p1y, PicMerge)
end loop

%I used this for my fighter game - so that the character would face right and left when you press right and left.

-----------------------------------
Hendo
Tue May 27, 2008 7:37 pm

RE:what is a boolean
-----------------------------------
yeah they're very useful if you only want to execute something if the variable hold true (or not)

So something like
if boolvar1 = true then
x=x+1
else
%if its not true
x=x-1 %do this instead
end if


-----------------------------------
Reality Check
Tue May 27, 2008 8:20 pm

Re: what is a boolean
-----------------------------------
It's simply a variable with only two possible states.  This is ideal for checking is a certain event has been reached and whatnot and is more ideal than using any other kind of variable because it'd use less memory.

-----------------------------------
Mackie
Tue May 27, 2008 8:25 pm

RE:what is a boolean
-----------------------------------
Actually a boolean is 8 bits, same as nat1 (Range of 0 - 255).

Surprising enough, I'd think it would only be 1 bit. On or off.

-----------------------------------
Tony
Tue May 27, 2008 8:37 pm

RE:what is a boolean
-----------------------------------
a boolean, as a variable, is indeed 8 bits. If you want to use less memory though, you could use a nat1 as an array of 8 boolean values.

-----------------------------------
Mackie
Tue May 27, 2008 8:51 pm

RE:what is a boolean
-----------------------------------
That is a very smart idea! I'll have to remember that.
