• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Boolean Values

 
Roger Sanchez
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A couple of other questions in preparation for an exam:
( ( x || ! ( y && z ) ) && ! ( y || z) )

( ( ! x && ( y || z ) ) || ( ! y || z))

Thanks again,
Roger
 
Paul Zill
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

not sure what the question is.
did you forget the values for x, y, & z?
 
Jaunty John
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
These will always resolve false if NOT true
 
Paul Zill
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jaunty John:
These will always resolve false if NOT true

if what not true
if:
boolean x = true;
boolean y = false;
boolean z = true;
than the first example would be true.
and second false.
if:
boolean x = false;
boolean y = false;
boolean z = true;
the the first is false and the second is true.
 
Roger Sanchez
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I forgot to put the variable values:
x = false, y = true, z = false
( ( x || ! ( y && z ) ) && ! ( y || z) )

x = false, y = true, z = false
( ( ! x && ( y || z ) ) || ( ! y || z))
Thanks again
 
Joe Pluta
Ranch Hand
Posts: 1376
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They might be trying to simplify the equation.
For example, take this one:
( ( x || ! ( y && z ) ) && ! ( y || z) )
If either y or z is true, this statement is false (because the right side of the *AND is false). So, plug false values for y and z into the left expression, getting (x || true), which removes x from the equation.
The whole thing factors downs to (!y && !z).
Similarly, after some careful manipulation, the second statement is (!x || !y || z).
Don't believe me? You could always try a truth table <grin>.
Joe
 
Roger Sanchez
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the quick reply. So, to check my understanding, both statements are false?
 
Joe Pluta
Ranch Hand
Posts: 1376
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nope. First is false, second is true. Quick runthrough:
x = false, y = true, z = false
( ( x || ! ( y && z ) ) && ! ( y || z) )
( ( F || ! ( T && F ) ) && ! ( T || F ) )
( ( F || ! ( F ) ) && ! ( T ) )
( ( F || T ) && F )
( T && F )
F
x = false, y = true, z = false
( ( ! x && ( y || z ) ) || ( ! y || z))
( ( ! F && ( T || F ) ) || ( ! T || F ) )
( ( T && T ) || ( F || F ) )
( T || F)
T

Joe
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic