Computer Science Canada

boolean help

Author:  why1234 [ Sat Jun 19, 2010 8:28 pm ]
Post subject:  boolean help

how do you use boolean?

Author:  DtY [ Sat Jun 19, 2010 8:39 pm ]
Post subject:  RE:boolean help

Turing:
boolean myBoolean := true;


If you have a more specific question, it might be possible to give meaningful help.

Author:  Euphoracle [ Sat Jun 19, 2010 8:43 pm ]
Post subject:  RE:boolean help

A boolean is one of two things: true or false. You can create a variable for like like this:

Turing:

var tehEpicBool : boolean := true


Anything you evaluate that is either true or false, right or wrong, is a boolean. Eg.

Turing:

put (5 > 3)
% this will print 'false'
put (9 >= 9)
% this will print 'true'
put (6 not= 4)
% this will print 'true'


Booleans are used to test conditions mostly.

eg.

Turing:

var i := 1
loop
    put i
    i := i + i
    exit when i > 99
    %when the value of i is greater than 99, this will be true and the 'exit' command will leave the loop
end

Author:  Monduman11 [ Sat Jun 19, 2010 10:43 pm ]
Post subject:  Re: RE:boolean help

Euphoracle @ Sat Jun 19, 2010 8:43 pm wrote:
A boolean is one of two things: true or false. You can create a variable for like like this:

Turing:

var tehEpicBool : boolean := true


Anything you evaluate that is either true or false, right or wrong, is a boolean. Eg.

Turing:

put (5 > 3)
% this will print 'false'
put (9 >= 9)
% this will print 'true'
put (6 not= 4)
% this will print 'true'


umm no offence but for the first 1 its true cause 5 is bigger than 3, i think u ment to write 3 > 5 not 5> 3

Booleans are used to test conditions mostly.

eg.

Turing:

var i := 1
loop
    put i
    i := i + i
    exit when i > 99
    %when the value of i is greater than 99, this will be true and the 'exit' command will leave the loop
end

Author:  Euphoracle [ Sat Jun 19, 2010 11:25 pm ]
Post subject:  RE:boolean help

whoops wrong key.

Author:  Cezna [ Sun Jun 20, 2010 7:52 am ]
Post subject:  Re: boolean help

If you are unclear on what a boolean variable is, I suggest you read through a tutorial on Turing, either the one from Holtsoft, or this one.

Author:  Insectoid [ Sun Jun 20, 2010 10:54 am ]
Post subject:  RE:boolean help

Or, even better, wikipedia, since booleans are global types and not restricted to Turing.

Think about it this way.

An integer can have any value from -max to max. A boolean can only have 0 to 1 (or false to true).

Author:  andrew. [ Sun Jun 20, 2010 11:50 am ]
Post subject:  RE:boolean help

It's not 0 to 1, it's 0 or 1.

Author:  TWizard [ Fri Jul 02, 2010 9:02 pm ]
Post subject:  RE:boolean help

Lol. You can do the same thing with number as you can with true or false. Boolean is mostly used in is statments try useing the built in guide or look though the online guides. Instead of posting something and not looking or just want to get the awnser. Here is a small example

Turing:


var Var : boolean
var number

put "What is 2 x 2 "
get number

if number = 4 then
Var := true
else
Var := false
end if
% To test if it was true or false

if Var = true then
put "Correct"
else
put "False"
end if



In truth thats the slack way I hope its useful and dont always think people will give the awnser your looking for with out know what you want.


: