# Make a number positive

This forum is currently in read-only mode.
0 favourites
• 5 posts
From the Asset Store
809 energetic male voice announcer phrases for casual & mobile games, such as puzzles, match, quest, casino, sports etc.
• 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.

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

ex:

abs(-2)=2

abs(2) =2

Edit:

Barely beat tulimide.

• 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^^

• thanks so much guys! thought it would be something simple :)

• ## Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• 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.