Public Group

#### Archived

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

# Bool keyword?

This topic is 5525 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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
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
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
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
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
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
Ever used C or C++?

##### Share on other sites
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
works even with floats:

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

##### Share on other sites
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
}

1. 1
2. 2
3. 3
Rutin
18
4. 4
JoeJ
14
5. 5

• 14
• 10
• 23
• 9
• 33
• ### Forum Statistics

• Total Topics
632631
• Total Posts
3007539
• ### Who's Online (See full list)

There are no registered users currently online

×