sign

Returns the sign of n.

Syntax:

sign(n);


Argument Description
n The number to get the sign of.


Returns: Integer


Description

This function returns whether a number is positive, negative or neither and returns 1, -1, 0 respectively. For example - sign(458) will return 1, sign(-5) will return -1 and sign(0) will return 0.


Example:

y += sign(y - mouse_y);

The above code will add 1, -1 or 0 onto y depending on the result of y - mouse_y.


Back: Real Number Functions
Next: ceil
© Copyright YoYo Games Ltd. 2018 All Rights Reserved