Does such function exist? I created my own but would like to use an official one:
private function opposite(number:Number):Number { if (number < 0) { number = Math.abs(number); } else { number = -(number); } return number; }
So, -5 becomes 5 and 3 becomes -3.
Edit: Forgive me for being stupid. I'm human. :)
A number with opposite signs is equidistant from 0 on the number line in opposite directions. The opposite of the opposite of a number is the number itself.
The opposite of 5 is -5.
sign() in Python. numpy. sign(array [, out]) function is used to indicate the sign of a number element-wise. For integer inputs, if array value is greater than 0 it returns 1, if array value is less than 0 it returns -1, and if array value 0 it returns 0.
yes it does...
return num*-1;
or simply
return -num;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With