Solved

# Converting a negative number to a positive number.

Posted on 2004-05-02

Hi All,

I need to convert a negative number to a positive number.

int i=0,j=0;

i--;

if( j == 100)

{

//I need to change the -i number to a +i number

//if i = -1050 I need to change it to i = +1050 by using

//the value of i.

//i will be a random number

}

if(j== 50)

{

//I need to change i back to the negative number

//by using the value of i.

}

In other words check the negative value and change it

to it's positive counter part and vice versa.

Is there a simple way to do this?

Thank you very much for your time,

AJ.