return Decimal.Round (d, decimals);
}
+#if NET_2_0
+ [MonoTODO]
+ public static decimal Round (decimal d, MidpointRounding mode)
+ {
+ if ((mode != MidpointRounding.ToEven) && (mode != MidpointRounding.AwayFromZero))
+ throw new ArgumentException ("The value '" + mode + "' is not valid for this usage of the type MidpointRounding.", "mode");
+
+ if (mode == MidpointRounding.ToEven)
+ return Round (d);
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public static decimal Round (decimal d, int decimals, MidpointRounding mode)
+ {
+ if ((mode != MidpointRounding.ToEven) && (mode != MidpointRounding.AwayFromZero))
+ throw new ArgumentException ("The value '" + mode + "' is not valid for this usage of the type MidpointRounding.", "mode");
+
+ if (mode == MidpointRounding.ToEven)
+ return Round (d, decimals);
+ throw new NotImplementedException ();
+ }
+#endif
+
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static double Round (double d);
[MethodImplAttribute (MethodImplOptions.InternalCall)]
private extern static double Round2 (double value, int digits);
+
+#if NET_2_0
+ public static double Round (double value, MidpointRounding mode)
+ {
+ if ((mode != MidpointRounding.ToEven) && (mode != MidpointRounding.AwayFromZero))
+ throw new ArgumentException ("The value '" + mode + "' is not valid for this usage of the type MidpointRounding.", "mode");
+
+ if (mode == MidpointRounding.ToEven)
+ return Round (value);
+ if (value > 0)
+ return Floor (value + 0.5);
+ else
+ return Ceiling (value - 0.5);
+ }
+
+ [MonoTODO]
+ public static double Round (double value, int digits, MidpointRounding mode)
+ {
+ if ((mode != MidpointRounding.ToEven) && (mode != MidpointRounding.AwayFromZero))
+ throw new ArgumentException ("The value '" + mode + "' is not valid for this usage of the type MidpointRounding.", "mode");
+
+ if (mode == MidpointRounding.ToEven)
+ return Round (value, digits);
+ throw new NotImplementedException ();
+ }
+#endif
+
public static int Sign (decimal value)
{
if (value > 0) return 1;