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