Project 1999

Project 1999 (/forums/index.php)
-   Rants and Flames (/forums/forumdisplay.php?f=30)
-   -   itsy bitsy bug (/forums/showthread.php?t=69664)

Truth 03-25-2012 11:20 PM

itsy bitsy bug
 
Code:

if (NULL == vertex->right() == vertex->left())
      // wutdo

Seems legit, if both values equal NULL, we wutdo.

THAT IS UNTIL we take apart and realize how the compiler sees this statement differently from us. NULL is #define'd as 0. Boolean values are represented by 1 = true, 0 = false

So if the right vertex was NULL, it would evaluate that part of the equation to True before moving on. Now we would basically have the following:

Code:

if (1 == vertex->left())
Not what we want at all.

Likewise, if vertex->right() was not NULL, it would evaluate to false. So now we have:

Code:

if (0 == vertex->left()
This is also wrong, since right had a value.

Correct:

Code:

if (vertex->right() == NULL && vertext->left() == NULL)
http://www.pc-xp.com/wp-content/uplo...bug_no_400.png

Kimm Barely 03-25-2012 11:55 PM

fuck uyou nerd

kazroth 03-25-2012 11:57 PM

is this EQ code? some sort of in-house language?

Truth 03-26-2012 01:56 AM

C-Increment

kazroth 03-26-2012 02:00 AM

ahh cool, those are some interesting looking if statements

Truth 03-28-2012 11:15 PM

http://www.bluffton.edu/~nesterd/java/SortingDemo.html


All times are GMT -4. The time now is 10:27 AM.

Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.