Tag Archives: boolean

My Wife’s Logic (or Women’s Logic Explained?)

For all of you who learned boolean algebra in your CS courses in college, I am sorry to be the bearer of bad news: your education was incomplete. The list of boolean tautologies and truth tables that you may have memorized or learned over time was wrong, with some startling and glaring errors.

To rectify this, I present some new truth.

First, an example in real life, which really happened. For context, Leticia is my wife, has beautiful, olive skin, with dark brown eyes, and hair with various colors of brown, and the little girl in discussion was as white as can be.

Leticia: Look at that little girl–she’s so beautiful! Do you think we’ll ever have a girl who looks like her?

Me: No.

L: So you think our daughter will be ugly!

M: Uhhh……no. I don’t think she’ll be white.

Transforming this little conversation into boolean logic:

A: This little girl is beautiful

B: Our future daughter will look like this girl

C: Our future daughter will be beautiful

So my wife says that AB–>C, and that if I say !B, then !B–>!C. I always knew that, but what I didn’t know is that the other options I thought existed aren’t actually valid! (i.e., that !B–>C is also true, or in other words, that C can be true regardless of the value of B) Who knew! So I present below corrected truth tables. Wikipedia, take note.

Standard Truth Table for Implication

Improved Truth Table for Implication

X Y X–>Y
F F T
F T T
T F F
T T T
X Y X?Y
F F T
F T F
T F F
T T T

So you see that the correct form of implication when dealing with this logic is the same as equality.

Now you know, beware.

Don’t use CArchive with native C++ type bool

I recently ran into an issue where I was trying to serialize a bool variable from a CArchive object.

Archiving it out, with this code, works fine:

//CArchive ar;
bool bFill;
ar << bFill;

But this code:

ar >> bFill

has problems. It compiles fine under Visual Studio 2003, but errors out under Visual C++ 6 with this error:

C2679: binary ‘>>’
: no operator defined which takes a right-hand operand of type ‘bool’
(or there is no acceptable conversion)

Very weird. There is some explanation here.

My resolution? Use BOOL instead. Sure, it’s actually an int and takes 4 bytes, not 1, but that’s a not a big deal in this case. And it’s more clear than using BYTE.