Mon Dec 5 15:14:59 CET 2005 Paolo Molaro <lupus@ximian.com>
[mono.git] / mcs / class / corlib / System / Math.cs
index e9ac0b5160ca57a862919a55f56e9caa0bd0af6e..9311c2b4628720ead82894194e3ad7526bb94704 100644 (file)
@@ -358,6 +358,30 @@ namespace System
                        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);
 
@@ -372,6 +396,33 @@ namespace System
                [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;
@@ -463,6 +514,9 @@ namespace System
                public extern static double Pow (double x, double y);
 
                [MethodImplAttribute (MethodImplOptions.InternalCall)]
+#if NET_2_0
+               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
+#endif
                public extern static double Sqrt (double x);
        }
 }