• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Computer Logic - (1 && !(0 || 1)) How does this equate 0?

Status
Not open for further replies.
Level 6
Joined
Apr 23, 2009
Messages
94
I'm sorry this is C++ and I figured it was close enough to Jass that someone would understand, I'm trying to learn C++ but the question they gave me was: Evaluate: !(1 && !(0 || 1))
A. True
B. False

And the answer ended up being True.
But for it to be true, !(1 && !(0 || 1)) would have to end up being !0.
0 = False, 1 = True.
Very confusing.
 
Level 10
Joined
Nov 28, 2008
Messages
655
Ok so 1 && False is False.
And False || True is True?

Thanks, that's all I needed to know.


That is pretty basic logic, yes.

True OR False = True
--because it is asking if either one is true

True AND False = False
--because it is asking if BOTH are true


Dr. Super: This kind of logic applies to programming logic in general, what is the problem with someone asking?
 
Can anyone break it down, i'm sure theres some little detail i'm missing..
(1 && !(0 || 1)) = 0 = False?

But how?

I can't make sense of how the first 1 somehow become 0.
Thanks.

Remember to start with the most nested quotes.

(1 && !(0 || 1))

False OR True is TRUE.

Right outside the parenthesis is NOT (think like the distributive property). NOT TRUE is False.

So now we have 1 && FALSE

TRUE && FALSE requires that both statements are true to return true; since they aren't, the answer is FALSE.

Hope that helped.
 
Status
Not open for further replies.
Top