# Boolean Values

Roger Sanchez

Greenhorn

Posts: 16

Paul Zill

Greenhorn

Posts: 28

Jaunty John

Greenhorn

Posts: 21

Paul Zill

Greenhorn

Posts: 28

posted 12 years ago

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.

- 0

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

Joe Pluta

Ranch Hand

Posts: 1376

posted 12 years ago

- 0

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

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

Joe Pluta

Ranch Hand

Posts: 1376

posted 12 years ago

- 0

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

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

I agree. Here's the link: http://aspose.com/file-tools |