Is there any syntax that will return the opposite value of plus and negative.
It should be one syntax that take the opposite. It must work both directions.
So for these examples:
Code:5 //This will return -5 -4 //This will return 4
This is a discussion on Plus to Negative value within the C++ Programming forums, part of the General Programming Boards category; Is there any syntax that will return the opposite value of plus and negative. It should be one syntax that ...
Is there any syntax that will return the opposite value of plus and negative.
It should be one syntax that take the opposite. It must work both directions.
So for these examples:
Code:5 //This will return -5 -4 //This will return 4
Well, if you have a number x, -x is such an opposite.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
That did work actually. So if you just write like in you example a - before x like -x.
This will make + to - and - to +. I thought that only would work from + to -.
Then if x is - from the beginning it must be a kind of multiplication -(-x) makes plus I beleive.
Thanks
Not multiplication, but just subtraction.Then if x is - from the beginning it must be a kind of multiplication -(-x) makes plus I beleive.
-(-x) = 0 - (-x) = 0 - (0 - x)
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Then I think I understand. Thanks.