public static int Sign (double value) { if (Double.IsNaN (value)) throw new ArithmeticException ("NAN"); if (value > 0) return 1; return (value == 0)? 0: -1; }