An incredibly simple trick, but to the maths inept of us, it's very useful, and might not be immediately obvious to someone who wants it (like me!)
*-1[/code:8y626699]
Dividing by zero opens up a portal to another dimension.
Prolly not try that one.
Develop games in your browser. Powerful, performant & highly capable.
In order to turn negatives into positives you can use absolute value.
abs(-20)
or
abs(20)
will give 20.
In order to turn negatives into positives you can use absolute value. abs(-20) or abs(20) will give 20.
Can you use abs to turn a positive into a negative?
No. Abs means Absolute Value. There is no opposite for that, that I am aware of.
Multiplying by -1 seems good for that.
No. Abs means Absolute Value. There is no opposite for that, that I am aware of. Multiplying by -1 seems good for that.
That's what I thought, would like to know of any problems that could arise from doing it this way?
That is the only way
-abs(x) will always return a negative number.
> Can you use abs to turn a positive into a negative? > -abs(x) will always return a negative number.
> Can you use abs to turn a positive into a negative?
>
Would that be more beneficial than using *-1?
-1 * -1 will give you 1... while -abs[-1 or 1] always will give you -1
I saw an add for great abs on youtube. Why is it an Add for Abs?
Oh wow. That is helpful. I wouldn't have thought of adding a negative to an expression.
-1 * -1 = 1
and
-1 * 1 = -1
Using abs() or -abs() keeps things simple, and adds a small bit of insurance.
I would use abs() or -abs() over *-1.