!(1 && !(0 || 1))
can u tell me what each part does and what it is?
try make it clear and simple for me please
and wondering on how to evaluate that
Printable View
!(1 && !(0 || 1))
can u tell me what each part does and what it is?
try make it clear and simple for me please
and wondering on how to evaluate that
we'll start from the inside: (0 || 1)Quote:
!(1 && !(0 || 1))
0 || 1 == 1 because it's testing if either 0 OR 1 are true, and one of them IS :)
then, we have the ! right before that, so that inverts the current value, so that now we have 0
then it tests (1 && 0) and since not BOTH of them aren't 1, then it equals a 0, making it !(0)
so, the end result is 1/true
-edit-
typo.....
To start, 0 is FALSE. And Anything other than 0 (in most cases 1) is TRUE. I assume the question is whether that statement evaluates to TRUE or FALSE. If you didnt know, ! means NOT. So if the statement is currently true, the ! changes it to false (as in NOT TRUE). && Means AND. A statement using && returns TRUE only if both are TRUE. || is OR. This returns TRUE if one of them are TRUE. And remember, you work your way out of the parantaces (Like Order of Operations in math class). So, the first thing you would evaluate is (0 || 1). This evaluates to 1 (TRUE) because like stated above, only one of the numbers needs to be TRUE for this to equal TRUE. So now, our statement looks like this:Quote:
Originally posted by yakabod
!(1 && !(0 || 1))
can u tell me what each part does and what it is?
try make it clear and simple for me please
and wondering on how to evaluate that
!(1 && !(1))
The next step is the !(1). This obviously returns 0 (or FALSE). So now we have:
!(1 && 0)
Now, since we know that both have to be TRUE for the && statement to be TRUE, we get this:
!(0)
!0 must be a value other than 0, which means your statement == TRUE
I hope I explained it clearly enough and didn't ramble too much :).
EDIT: Looks like jverkoey beat me to it :)
Quote:
The next step is the !(1). This obviously returns 0 (or FALSE). So now we have:
So how does this become false? because ! means NOT right? so making...
!(1) //Not 1 But 0
will that be right?