• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

The story of notfred and the excessively long "if" statement.

notfred

Lifer
Bah, I think I confused myself 😕

if (((($y1 - $slopep * $x1 > $yp1 - $slopep * $xp1)&amp;&amp;($y2 - $slopep * $x2 < $yp1 - $slopep * $xp1))||(($y1 - $slopep * $x1 < $yp1 - $slopep * $xp1)&amp;&amp;($y2 - $slopep * $x2 > $yp1 - $slopep * $xp1)))&amp;&amp;((($yp1 - $slope * $xp1 > $y1 - $slope * $x1)&amp;&amp;($yp2 - $slope * $xp2 < $y1 - $slope * $x1))||(($yp1 - $slope * $xp1 < $y1 - $slope * $x1)&amp;&amp;($yp2 - $slope * $xp2 > $y1 - $slope * $x1))))
{
return 1;
}

And yes, it's formatted much more nicely in my actual code... but damn, it's one hell of a long 'if'.

Nicely formatted:
 
Have fun if you ever need to modfiy it 🙂

That's one nice thing about compiled langauges, there's no penalty for making it legible by setting a bunch of booleans outside the if.
 
How does this relate to doom 3?

😛

The last thing I worked on (just a bourne shell script) had enough nested ifs to confused the heck out of myself.
 
Originally posted by: BingBongWongFooey
There are these cool things called functions!

Bingo. How many times did you recalculate the same thing? There seems to be one function recoded 16 times. And you'd only have to call it 6 times by my count to consider the different inputs. But congrats for having the guts to post that and have it critiqued 😉
 
Back
Top