#### Archived

This topic is now archived and is closed to further replies.

# Bool keyword?

## Recommended Posts

jcdenton999    122
Hi After seeing the reply''s for the prime number program that I coudn''t get the solution to, I can see that evryone that gave examples used the keywords bool, true and false. They haven''t come up in the book yet so what exactly do they do. Are they necessary, because I managed to write the program without using it? Thank you

##### Share on other sites
EL    122
bool stands for boolean. A boolean variable can only have 2 possible values: true or false. If it''s not true, it''s false and vice versa.
I suggest you keep on reading

##### Share on other sites
Guest Anonymous Poster
Is true that a boolean isn''t really necessary you could even make your own if you like:

#define True 1
#define False 0

you don''t need to do this of course that''s why there''s the bool statement, in a short answer be thankful you have them around they ease work a little bit. They''re kinda of like pointers when you first look at them you think to yourself what use is this going to be" and the truth is they are really useful and there''s stuff you can''t do without them but that''s something different.

##### Share on other sites
Krakken    122
Also, a boolean can be used with integers...
0 is always false and any other number, including negative numbers, are always true.

[edited by - Krakken on August 8, 2003 3:40:41 PM]

##### Share on other sites
sSimontis    100
You can use integers instead of boolean values. But I find boolean values easier to use.

Scott Simontis
If it wasn''t for C, we''d be using BASI, PASAL and OBOL

##### Share on other sites
evillive2    779
quote:
Krakken: Also, a boolean can be used with integers...
0 is always false and any other number, including negative numbers, are always true.

[edited by - Krakken on August 8, 2003 3:40:41 PM]

I was under the impression negative numbers are always false. I have yet to come across a system that sees -1 as TRUE.

##### Share on other sites
Martee    476
Ever used C or C++?

##### Share on other sites
FtMonkey    122
quote:
Original post by evillive2
quote:
Krakken: Also, a boolean can be used with integers...
0 is always false and any other number, including negative numbers, are always true.

[edited by - Krakken on August 8, 2003 3:40:41 PM]

I was under the impression negative numbers are always false. I have yet to come across a system that sees -1 as TRUE.

Umm what's wrong with negative numbers? They are almost the same thing as positive numbers they just happen to be negative what do you have against them? Zero should be false because it doesn't have any value but any other number does have a value...so it would make sense that it returns true...

[edited by - FtMonkey on August 9, 2003 2:55:45 AM]

##### Share on other sites
Guest Anonymous Poster
works even with floats:

true:> 0.000000000000001 1.010 -0.000000000001
false:> 0.0000000000000 0.0000000000000000000000000000000000

##### Share on other sites
Naku    151
quote:
Original post by evillive2
quote:
Krakken: Also, a boolean can be used with integers...
0 is always false and any other number, including negative numbers, are always true.

[edited by - Krakken on August 8, 2003 3:40:41 PM]

I was under the impression negative numbers are always false. I have yet to come across a system that sees -1 as TRUE.

Try it in an if() statement.
if(-1)
{
//the code will get here
}

##### Share on other sites
Arch@on    100
The variable itself has been named After George Boole who duscivered true and false statements through the law of contradiction. Boolean variable means that it can have either two values, true or false, but in computer arithmetic these are intrepeded as 0 and 1 due to simplicity.

x^2 = x

"Nothing can''t at the same time belong and not belong to given class x", which is basically a rephrase of aristotle''s rule of contradiction in mathematical form.

##### Share on other sites
evillive2    779
Ok, my bad, sorry for the confusion. See, it is places like this that make us remember the little things. A lot of times I use < 0 as my invalid statement because 0 would be valid for my purposes. Just goes to show how not to open your mouth unless your ready to taste feet.
int main(){	bool bBool = (bool)-1;	if ( !(bBool) )	    printf( "!(bBool) = true\n\r" );	if ( !(-1) )	    printf( "!(-1) = true;\n\r" );	if ( bBool )	    printf( "(bBool) = true\n\r" );	if ( (-1) )		printf( "(-1) = true\n\r" );	return getch();}

##### Share on other sites
Arch@on    100
Well, Boole''s logic is somewhat old when related to computer science. In fact it is much better to use 32bit int in every single way.

You can perform the same exact operations as with "bools".
A bool is not considered to be a class of anything.
You are not limited to two possible answers with ints.
You can perform much complicated logic with integers(not in C/C++, because the language has been dummed like that.)
Frege''s s-expressions have been considered much better ever since they were first implemented.

And some 1337 d00ds will probably bring up the point D00D 32 BIT INT IS SO FAAST D000D U''ll GAIN 1FPS D00D