Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Help with algorithm in C
Index -> Programming, C -> C Help
Goto page Previous  1, 2
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Dreadnought




PostPosted: 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
Sponsor
sponsor
Insectoid




PostPosted: 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




PostPosted: 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)
Display posts from previous:   
   Index -> Programming, C -> C Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 2 of 2  [ 18 Posts ]
Goto page Previous  1, 2
Jump to:   


Style:  
Search: