# The difference between (-(a*b)) and ((-a)*b)

One of our teachers said that there is just one example that there is a difference between `(-(a*b))` and `((-a)*b)`. He said by using two's complement you can find one.

• I'm voting to close this question as off-topic because it is about mathematical logic and not about a programming concept. – user53019 Feb 15 '15 at 1:53
• Get a sheet of paper and write out some examples. Work through the order of precedence for the operations and you'll find what the teacher was getting at, or if they were wrong, or if you misunderstood what they said. – user53019 Feb 15 '15 at 1:54
• @GlenH7 But this is related to my compiler course. But maybe you are right. – TTS Feb 15 '15 at 1:54
• Operational precedence is inherited by programming from mathematics, not the other way around. Mathematics can safely claim to predate programming by more than a few years... – user53019 Feb 15 '15 at 1:56
• Mathematically, they're equal. This seems like a programming question because I think there is an example under two's complement notation they the two are different. That being said, we don't do your homework here. Ask your teacher, and if they don't answer then either they were wrong or it's homework. – raptortech97 Feb 15 '15 at 2:27