public static double Ceiling(double a)
{
- double b = (double)((long)a);
+ if (Double.IsNaN(a)){
+ return Double.NaN;
+ }
+
+ if (Double.IsNegativeInfinity(a)){
+ return Double.NegativeInfinity;
+ }
+
+ if (Double.IsPositiveInfinity(a)){
+ return Double.PositiveInfinity;
+ }
+
+ double b = (double)((long)a);
return (b < a)? b+1: b;
}
public static double Floor(double d) {
- double b = (double)((long)d);
+ if (Double.IsNaN(d)){
+ return Double.NaN;
+ }
+
+ if (Double.IsNegativeInfinity(d)){
+ return Double.NegativeInfinity;
+ }
+
+ if (Double.IsPositiveInfinity(d)){
+ return Double.PositiveInfinity;
+ }
+
+ double b = (double)((long)d);
return (d < 0 && d != b) ? --b : b;
}
public static double IEEERemainder(double x, double y)
}
public static decimal Round(decimal d, int decimals)
{
- long p = 10;
+ long p = 1;
int c;
decimal retval = d;
if (decimals < 0 || decimals > 15)
}
}
public static double Round(double value, int digits) {
- long p = 10;
+ long p = 1;
int c;
double retval = value;
if (digits < 0 || digits > 15)
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static double Log10 (double x);
+ public static double Pow (double x, double y) {
+ if (Double.IsNaN (x) || Double.IsNaN (y))
+ return Double.NaN;
+ if (Double.IsNegativeInfinity (x))
+ if (((int)y & 1) == 1)
+ return Double.NegativeInfinity;
+ else
+ return Double.PositiveInfinity;
+ if (Double.IsPositiveInfinity (x))
+ if (Double.IsNegativeInfinity (y))
+ return 0;
+ else
+ return Double.PositiveInfinity;
+ if (Double.IsNegativeInfinity (y) || Double.IsPositiveInfinity (y))
+ return Double.NaN;
+
+ return PowImpl (x, y);
+ }
+
[MethodImplAttribute (MethodImplOptions.InternalCall)]
- public extern static double Pow (double x, double y);
+ public extern static double PowImpl (double x, double y);
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static double Sqrt (double x);