Jump to content
  • Advertisement

Archived

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

jcdenton999

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
Guest Anonymous Poster
works even with floats:

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

Share this post


Link to post
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
}

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!