Mon Dec 5 15:14:59 CET 2005 Paolo Molaro <lupus@ximian.com>
[mono.git] / mcs / class / corlib / System / Math.cs
index 5e6aac326f7489e2e62d8a376c507f8e25aa6820..9311c2b4628720ead82894194e3ad7526bb94704 100644 (file)
@@ -144,7 +144,7 @@ namespace System
                }
 
 #if NET_2_0
-               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, CER.Success)]
+               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
 #endif
                public static byte Max (byte val1, byte val2)
                {
@@ -152,7 +152,7 @@ namespace System
                }
 
 #if NET_2_0
-               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, CER.Success)]
+               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
 #endif
                public static decimal Max (decimal val1, decimal val2)
                {
@@ -160,7 +160,7 @@ namespace System
                }
 
 #if NET_2_0
-               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, CER.Success)]
+               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
 #endif
                public static double Max (double val1, double val2)
                {
@@ -171,7 +171,7 @@ namespace System
                }
 
 #if NET_2_0
-               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, CER.Success)]
+               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
 #endif
                public static float Max (float val1, float val2)
                {
@@ -182,7 +182,7 @@ namespace System
                }
 
 #if NET_2_0
-               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, CER.Success)]
+               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
 #endif
                public static int Max (int val1, int val2)
                {
@@ -190,7 +190,7 @@ namespace System
                }
 
 #if NET_2_0
-               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, CER.Success)]
+               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
 #endif
                public static long Max (long val1, long val2)
                {
@@ -198,7 +198,7 @@ namespace System
                }
 
 #if NET_2_0
-               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, CER.Success)]
+               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
 #endif
                [CLSCompliant (false)]
                public static sbyte Max (sbyte val1, sbyte val2)
@@ -207,7 +207,7 @@ namespace System
                }
 
 #if NET_2_0
-               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, CER.Success)]
+               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
 #endif
                public static short Max (short val1, short val2)
                {
@@ -215,7 +215,7 @@ namespace System
                }
 
 #if NET_2_0
-               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, CER.Success)]
+               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
 #endif
                [CLSCompliant (false)]
                public static uint Max (uint val1, uint val2)
@@ -224,7 +224,7 @@ namespace System
                }
 
 #if NET_2_0
-               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, CER.Success)]
+               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
 #endif
                [CLSCompliant (false)]
                public static ulong Max (ulong val1, ulong val2)
@@ -233,7 +233,7 @@ namespace System
                }
 
 #if NET_2_0
-               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, CER.Success)]
+               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
 #endif
                [CLSCompliant (false)]
                public static ushort Max (ushort val1, ushort val2)
@@ -242,7 +242,7 @@ namespace System
                }
 
 #if NET_2_0
-               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, CER.Success)]
+               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
 #endif
                public static byte Min (byte val1, byte val2)
                {
@@ -250,7 +250,7 @@ namespace System
                }
 
 #if NET_2_0
-               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, CER.Success)]
+               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
 #endif
                public static decimal Min (decimal val1, decimal val2)
                {
@@ -258,7 +258,7 @@ namespace System
                }
 
 #if NET_2_0
-               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, CER.Success)]
+               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
 #endif
                public static double Min (double val1, double val2)
                {
@@ -269,7 +269,7 @@ namespace System
                }
 
 #if NET_2_0
-               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, CER.Success)]
+               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
 #endif
                public static float Min (float val1, float val2)
                {
@@ -280,7 +280,7 @@ namespace System
                }
 
 #if NET_2_0
-               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, CER.Success)]
+               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
 #endif
                public static int Min (int val1, int val2)
                {
@@ -288,7 +288,7 @@ namespace System
                }
 
 #if NET_2_0
-               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, CER.Success)]
+               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
 #endif
                public static long Min (long val1, long val2)
                {
@@ -296,7 +296,7 @@ namespace System
                }
 
 #if NET_2_0
-               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, CER.Success)]
+               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
 #endif
                [CLSCompliant (false)]
                public static sbyte Min (sbyte val1, sbyte val2)
@@ -305,7 +305,7 @@ namespace System
                }
 
 #if NET_2_0
-               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, CER.Success)]
+               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
 #endif
                public static short Min (short val1, short val2)
                {
@@ -313,7 +313,7 @@ namespace System
                }
 
 #if NET_2_0
-               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, CER.Success)]
+               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
 #endif
                [CLSCompliant (false)]
                public static uint Min (uint val1, uint val2)
@@ -322,7 +322,7 @@ namespace System
                }
 
 #if NET_2_0
-               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, CER.Success)]
+               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
 #endif
                [CLSCompliant (false)]
                public static ulong Min (ulong val1, ulong val2)
@@ -331,7 +331,7 @@ namespace System
                }
 
 #if NET_2_0
-               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, CER.Success)]
+               [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
 #endif
                [CLSCompliant (false)]
                public static ushort Min (ushort val1, ushort val2)
@@ -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);
        }
 }