# Make a number positive

### » Sat Oct 01, 2011 6:09 am

Is there an easy simple way to make a number positive in an expression? For instance, the value I'm using could range from -200 to 200, but if its -200 I want it to be 200.

I know you can do *-1, while its good for making negative numbers positive it will make the positive numbers negative. But I only want positive.

At the moment I'm doing an X>0?A:B thing, but I'm just interested to know if there is a different method I could use in an expression.

alspal2011-10-01 06:09:53
B
166
S
80
G
22
Posts: 1,811
Reputation: 24,699

### » Sat Oct 01, 2011 6:25 am

The easiest would be to use the Absolute Value expression or "abs()".

ex:
abs(-2)=2
abs(2) =2

Edit:
Barely beat tulimide.R0J0hound2011-10-01 06:27:18
B
97
S
36
G
131
Posts: 5,514
Reputation: 83,466

### » Sat Oct 01, 2011 6:25 am

there's the absolute expression: abs()
it returns a value without sign (that is: the positive representation)

abs(-200) = 200
abs(200) = 200

ROJO was quicker^^tulamide2011-10-01 06:26:04
B
24
S
8
G
10
Posts: 1,821
Reputation: 8,289

### » Sat Oct 01, 2011 6:44 am

thanks so much guys! thought it would be something simple :)
B
166
S
80
G
22
Posts: 1,811
Reputation: 24,699

### » Sat Oct 01, 2011 10:00 am

R0J0hound - Posted: Today at 6:25am
Edited by R0J0hound - Today at 6:27am

tulamide - Posted: Today at 6:25am
Edited by tulamide - Today at 6:26am

Fastest guns in the west. It is even more amusing as your formatting for both the posts and edits is so similar. Good work chaps.

B
9
S
2
G
4
Posts: 346
Reputation: 2,726