Posted: Sun Mar 09, 2014 3:53 pm Post subject: Re: Help with algorithm in C
Panphobia wrote:
I figured it out, the C compiler I am using is weird, when building a propositional statement like a&&b == b && c you need brackets, (a && b) == (b && c)
That's not your compiler, that's the C standard, (look up operator precedence).
Did that come up in the snippet you posted?
Sponsor Sponsor
Insectoid
Posted: Sun Mar 09, 2014 3:56 pm Post subject: RE:Help with algorithm in C
That's not an issue with the compiler, that's part of the C spec. == takes precedence over &&. In your situation, it evaluates b == b first, which of course is true, so your equation simplifies to a&&c.
But yeah, the brackets would have fixed it.
EDIT: Damnit, Dreadnaught.
Panphobia
Posted: Sun Mar 09, 2014 3:59 pm Post subject: RE:Help with algorithm in C
No it was the other way around, a == b && b == c, sorry, as you can see the xEnd = uX && yEnd == uY, so I needed to change it to (xEnd == uX) && (yEnd == uY)