# super fast question

This is a discussion on super fast question within the C Programming forums, part of the General Programming Boards category; how do you eliminate the - sign of an negative integer regardless if the integer is positive or negative...

1. ## super fast question

how do you eliminate the - sign of an negative integer regardless if the integer is positive or negative

2. The abs function declared in <stdlib.h> or <math.h>.

3. Code:
```if (i < 0) {
i = -i;
}
...or even...
i = abs(i);```

4. or you can use if
Code:
```if (x < 0)
x = -x;```
or
Code:
`x = (x > 0)? x : (-x);`

5. you can use the fbas funciotn as well

fabs(-8.75) -- > 8.75

synatx : - fabs( value) --> declared in <math.h>

s.s.harish

6. x-=(x+-1);

7. Originally Posted by Quantum1024
x-=(x+-1);

Well, it works perfectly for x = 1 and x = -1. Did you test it for other values of x?

(I hope this isn't the beginning of a continuing thread that shows more and more baroque expressions that set things equal to 1. I really hate that stuff.)

Regards,

Dave

"If it ain't baroque, don't fix it."