sign function

int sign(
  1. num x
)

Returns the sign of a number.

Example:

print(sign(-15));  // Output: -1

Implementation

int sign(num x) {
  return x < 0 ? -1 : (x > 0 ? 1 : 0);
}