signum method Null safety

int signum(
  1. double num
)

The signum function.

Returns 1 if num > 0, -1 if num < 0, and 0 if num = 0

Implementation

static int signum(double num) {
  if (num < 0) {
    return -1;
  } else if (num == 0) {
    return 0;
  } else {
    return 1;
  }
}