Archived

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

Drevay

Finally know the diff between !, &&, and ||

Recommended Posts

Drevay    100
Yep, I finally figured it out....just to make sure !( true || false) && false) = true .... right? and !( true || false && true) = false, right? Just making sure, if I''m wrong, please correct me :D Of course that''''s just my opinion, I could be wrong. -)(-Dennis Miller-)(-

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
It''s often preferred to use parenthesis for clarity.

But simply put:

!true = false
!false = true

true || true = true
true || false = true
false || true = true
false || false = false

true && true = true
true && false = false
false && true = false
false && false = false

Share this post


Link to post
Share on other sites
Drevay    100
petewood, the first one IS correct, consider the parenthesis around the || statement, then you''ll realize the answer.

And thankyou anonymous poster :D

Much appreciated!

Share this post


Link to post
Share on other sites
petewood    819
quote:
you: if I''m wrong, please correct me


quote:
me: the first one is incorrect


quote:
you: petewood, the first one IS correct, consider the parenthesis around the || statement, then you''ll realize the answer.


I should have been more exact.

The expression is malformed. There are not enough parentheses for it to be correct. The missing bracket could be be placed in a number of places, so it is not possible to guess the meaning.

If you write it out as a proper expression then we''ll be able to tell you whether it is correct or not.

Share this post


Link to post
Share on other sites
Bankie    122
quote:
Original post by petewood
the first one is incorrect


It''s this kind of thing that makes newbies feel uncomfortable about asking questions. Yes, the answer could be different depending upon where the missing bracket is put, but in this case it was fairly obvious where it was supposed to be, and in any case just saying "the first one is incorrect" is totally unhelpful.

www.bankie.com

Share this post


Link to post
Share on other sites
Turt99    283
quote:
Original post by Drevay
petewood, the first one IS correct, consider the parenthesis around the || statement, then you'll realize the answer.

And thankyou anonymous poster :D

Much appreciated!



!( true || false) && false = true
say that was the first statement

then
!true && false = true

then
false && false = true

then
false = true

I don't understand that, and if you do the brakets the other way that the 2 statements are the exact same

***EDIT*** - oooh wait I see, the && is done before the || and the first statement you add a ( instead of removing a ).. nevermind what I said, although I guess what I wrote out is correct its not exactly what we are looking for

Please visit Turt99 Productions

[edited by - Turt99 on March 6, 2003 11:49:01 AM]

Share this post


Link to post
Share on other sites
mstein    122
i think he meant this:

!((true || false) && false) = true
!(true && false) = true
!(false) = true
true = true

notice how in his the first parenthese is gone

you are reading it like this
!(true || false) && false.

it makes sense to me

Share this post


Link to post
Share on other sites
Drevay    100
Oh, sorry :O

instead of

!(true || false) && true)

it should have been

!((true || false) && true)

really sorry about that

Of course that''''s just my opinion, I could be wrong.
-)(-Dennis Miller-)(-

Share this post


Link to post
Share on other sites