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

Printable View

- 02-24-2008CodingPlus to Negative value
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

- 02-24-2008laserlight
Well, if you have a number x, -x is such an opposite.

- 02-24-2008Coding
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 - 02-24-2008laserlightQuote:

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) - 02-24-2008Coding
Then I think I understand. Thanks.