mscorlib(4.0.0.0) API with additions
Math.cs
4 using System.Security;
5 
6 namespace System
7 {
9  [__DynamicallyInvokable]
10  public static class Math
11  {
12  private static double doubleRoundLimit = 1E+16;
13 
14  private const int maxRoundingDigits = 15;
15 
16  private static double[] roundPower10Double = new double[16]
17  {
18  1.0,
19  10.0,
20  100.0,
21  1000.0,
22  10000.0,
23  100000.0,
24  1000000.0,
25  10000000.0,
26  100000000.0,
27  1000000000.0,
28  10000000000.0,
29  100000000000.0,
30  1000000000000.0,
31  10000000000000.0,
32  100000000000000.0,
33  1E+15
34  };
35 
37  [__DynamicallyInvokable]
38  public const double PI = 3.1415926535897931;
39 
41  [__DynamicallyInvokable]
42  public const double E = 2.7182818284590451;
43 
48  [MethodImpl(MethodImplOptions.InternalCall)]
49  [SecuritySafeCritical]
50  [__DynamicallyInvokable]
51  public static extern double Acos(double d);
52 
57  [MethodImpl(MethodImplOptions.InternalCall)]
58  [SecuritySafeCritical]
59  [__DynamicallyInvokable]
60  public static extern double Asin(double d);
61 
66  [MethodImpl(MethodImplOptions.InternalCall)]
67  [SecuritySafeCritical]
68  [__DynamicallyInvokable]
69  public static extern double Atan(double d);
70 
77  [MethodImpl(MethodImplOptions.InternalCall)]
78  [SecuritySafeCritical]
79  [__DynamicallyInvokable]
80  public static extern double Atan2(double y, double x);
81 
85  [__DynamicallyInvokable]
86  public static decimal Ceiling(decimal d)
87  {
88  return decimal.Ceiling(d);
89  }
90 
94  [MethodImpl(MethodImplOptions.InternalCall)]
95  [SecuritySafeCritical]
96  [__DynamicallyInvokable]
97  public static extern double Ceiling(double a);
98 
102  [MethodImpl(MethodImplOptions.InternalCall)]
103  [SecuritySafeCritical]
104  [__DynamicallyInvokable]
105  public static extern double Cos(double d);
106 
110  [MethodImpl(MethodImplOptions.InternalCall)]
111  [SecuritySafeCritical]
112  [__DynamicallyInvokable]
113  public static extern double Cosh(double value);
114 
118  [__DynamicallyInvokable]
119  public static decimal Floor(decimal d)
120  {
121  return decimal.Floor(d);
122  }
123 
127  [MethodImpl(MethodImplOptions.InternalCall)]
128  [SecuritySafeCritical]
129  [__DynamicallyInvokable]
130  public static extern double Floor(double d);
131 
132  [SecuritySafeCritical]
133  private unsafe static double InternalRound(double value, int digits, MidpointRounding mode)
134  {
135  if (Abs(value) < doubleRoundLimit)
136  {
137  double num = roundPower10Double[digits];
138  value *= num;
139  if (mode == MidpointRounding.AwayFromZero)
140  {
141  double value2 = SplitFractionDouble(&value);
142  if (Abs(value2) >= 0.5)
143  {
144  value += (double)Sign(value2);
145  }
146  }
147  else
148  {
149  value = Round(value);
150  }
151  value /= num;
152  }
153  return value;
154  }
155 
156  [SecuritySafeCritical]
157  private unsafe static double InternalTruncate(double d)
158  {
159  SplitFractionDouble(&d);
160  return d;
161  }
162 
166  [MethodImpl(MethodImplOptions.InternalCall)]
167  [SecuritySafeCritical]
168  [__DynamicallyInvokable]
169  public static extern double Sin(double a);
170 
174  [MethodImpl(MethodImplOptions.InternalCall)]
175  [SecuritySafeCritical]
176  [__DynamicallyInvokable]
177  public static extern double Tan(double a);
178 
182  [MethodImpl(MethodImplOptions.InternalCall)]
183  [SecuritySafeCritical]
184  [__DynamicallyInvokable]
185  public static extern double Sinh(double value);
186 
190  [MethodImpl(MethodImplOptions.InternalCall)]
191  [SecuritySafeCritical]
192  [__DynamicallyInvokable]
193  public static extern double Tanh(double value);
194 
198  [MethodImpl(MethodImplOptions.InternalCall)]
199  [SecuritySafeCritical]
200  [__DynamicallyInvokable]
201  public static extern double Round(double a);
202 
209  [__DynamicallyInvokable]
210  public static double Round(double value, int digits)
211  {
212  if (digits < 0 || digits > 15)
213  {
214  throw new ArgumentOutOfRangeException("digits", Environment.GetResourceString("ArgumentOutOfRange_RoundingDigits"));
215  }
216  return InternalRound(value, digits, MidpointRounding.ToEven);
217  }
218 
225  [__DynamicallyInvokable]
226  public static double Round(double value, MidpointRounding mode)
227  {
228  return Round(value, 0, mode);
229  }
230 
240  [__DynamicallyInvokable]
241  public static double Round(double value, int digits, MidpointRounding mode)
242  {
243  if (digits < 0 || digits > 15)
244  {
245  throw new ArgumentOutOfRangeException("digits", Environment.GetResourceString("ArgumentOutOfRange_RoundingDigits"));
246  }
247  if (mode < MidpointRounding.ToEven || mode > MidpointRounding.AwayFromZero)
248  {
249  throw new ArgumentException(Environment.GetResourceString("Argument_InvalidEnumValue", mode, "MidpointRounding"), "mode");
250  }
251  return InternalRound(value, digits, mode);
252  }
253 
258  [__DynamicallyInvokable]
259  public static decimal Round(decimal d)
260  {
261  return decimal.Round(d, 0);
262  }
263 
271  [__DynamicallyInvokable]
272  public static decimal Round(decimal d, int decimals)
273  {
274  return decimal.Round(d, decimals);
275  }
276 
284  [__DynamicallyInvokable]
285  public static decimal Round(decimal d, MidpointRounding mode)
286  {
287  return decimal.Round(d, 0, mode);
288  }
289 
300  [__DynamicallyInvokable]
301  public static decimal Round(decimal d, int decimals, MidpointRounding mode)
302  {
303  return decimal.Round(d, decimals, mode);
304  }
305 
306  [MethodImpl(MethodImplOptions.InternalCall)]
307  [SecurityCritical]
308  private unsafe static extern double SplitFractionDouble(double* value);
309 
313  [__DynamicallyInvokable]
314  public static decimal Truncate(decimal d)
315  {
316  return decimal.Truncate(d);
317  }
318 
336  [__DynamicallyInvokable]
337  public static double Truncate(double d)
338  {
339  return InternalTruncate(d);
340  }
341 
352  [MethodImpl(MethodImplOptions.InternalCall)]
353  [SecuritySafeCritical]
354  [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
355  [__DynamicallyInvokable]
356  public static extern double Sqrt(double d);
357 
370  [MethodImpl(MethodImplOptions.InternalCall)]
371  [SecuritySafeCritical]
372  [__DynamicallyInvokable]
373  public static extern double Log(double d);
374 
387  [MethodImpl(MethodImplOptions.InternalCall)]
388  [SecuritySafeCritical]
389  [__DynamicallyInvokable]
390  public static extern double Log10(double d);
391 
395  [MethodImpl(MethodImplOptions.InternalCall)]
396  [SecuritySafeCritical]
397  [__DynamicallyInvokable]
398  public static extern double Exp(double d);
399 
404  [MethodImpl(MethodImplOptions.InternalCall)]
405  [SecuritySafeCritical]
406  [__DynamicallyInvokable]
407  public static extern double Pow(double x, double y);
408 
413  [__DynamicallyInvokable]
414  public static double IEEERemainder(double x, double y)
415  {
416  if (double.IsNaN(x))
417  {
418  return x;
419  }
420  if (double.IsNaN(y))
421  {
422  return y;
423  }
424  double num = x % y;
425  if (double.IsNaN(num))
426  {
427  return double.NaN;
428  }
429  if (num == 0.0 && double.IsNegative(x))
430  {
431  return double.NegativeZero;
432  }
433  double num2 = num - Abs(y) * (double)Sign(x);
434  if (Abs(num2) == Abs(num))
435  {
436  double num3 = x / y;
437  double value = Round(num3);
438  if (Abs(value) > Abs(num3))
439  {
440  return num2;
441  }
442  return num;
443  }
444  if (Abs(num2) < Abs(num))
445  {
446  return num2;
447  }
448  return num;
449  }
450 
456  [CLSCompliant(false)]
457  [__DynamicallyInvokable]
458  public static sbyte Abs(sbyte value)
459  {
460  if (value >= 0)
461  {
462  return value;
463  }
464  return AbsHelper(value);
465  }
466 
467  private static sbyte AbsHelper(sbyte value)
468  {
469  if (value == sbyte.MinValue)
470  {
471  throw new OverflowException(Environment.GetResourceString("Overflow_NegateTwosCompNum"));
472  }
473  return (sbyte)(-value);
474  }
475 
481  [__DynamicallyInvokable]
482  public static short Abs(short value)
483  {
484  if (value >= 0)
485  {
486  return value;
487  }
488  return AbsHelper(value);
489  }
490 
491  private static short AbsHelper(short value)
492  {
493  if (value == short.MinValue)
494  {
495  throw new OverflowException(Environment.GetResourceString("Overflow_NegateTwosCompNum"));
496  }
497  return (short)(-value);
498  }
499 
505  [__DynamicallyInvokable]
506  public static int Abs(int value)
507  {
508  if (value >= 0)
509  {
510  return value;
511  }
512  return AbsHelper(value);
513  }
514 
515  private static int AbsHelper(int value)
516  {
517  if (value == int.MinValue)
518  {
519  throw new OverflowException(Environment.GetResourceString("Overflow_NegateTwosCompNum"));
520  }
521  return -value;
522  }
523 
529  [__DynamicallyInvokable]
530  public static long Abs(long value)
531  {
532  if (value >= 0)
533  {
534  return value;
535  }
536  return AbsHelper(value);
537  }
538 
539  private static long AbsHelper(long value)
540  {
541  if (value == long.MinValue)
542  {
543  throw new OverflowException(Environment.GetResourceString("Overflow_NegateTwosCompNum"));
544  }
545  return -value;
546  }
547 
551  [MethodImpl(MethodImplOptions.InternalCall)]
552  [SecuritySafeCritical]
553  [__DynamicallyInvokable]
554  public static extern float Abs(float value);
555 
559  [MethodImpl(MethodImplOptions.InternalCall)]
560  [SecuritySafeCritical]
561  [__DynamicallyInvokable]
562  public static extern double Abs(double value);
563 
567  [__DynamicallyInvokable]
568  public static decimal Abs(decimal value)
569  {
570  return decimal.Abs(value);
571  }
572 
577  [CLSCompliant(false)]
578  [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
579  [NonVersionable]
580  [__DynamicallyInvokable]
581  public static sbyte Max(sbyte val1, sbyte val2)
582  {
583  if (val1 < val2)
584  {
585  return val2;
586  }
587  return val1;
588  }
589 
594  [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
595  [NonVersionable]
596  [__DynamicallyInvokable]
597  public static byte Max(byte val1, byte val2)
598  {
599  if (val1 < val2)
600  {
601  return val2;
602  }
603  return val1;
604  }
605 
610  [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
611  [NonVersionable]
612  [__DynamicallyInvokable]
613  public static short Max(short val1, short val2)
614  {
615  if (val1 < val2)
616  {
617  return val2;
618  }
619  return val1;
620  }
621 
626  [CLSCompliant(false)]
627  [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
628  [NonVersionable]
629  [__DynamicallyInvokable]
630  public static ushort Max(ushort val1, ushort val2)
631  {
632  if (val1 < val2)
633  {
634  return val2;
635  }
636  return val1;
637  }
638 
643  [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
644  [NonVersionable]
645  [__DynamicallyInvokable]
646  public static int Max(int val1, int val2)
647  {
648  if (val1 < val2)
649  {
650  return val2;
651  }
652  return val1;
653  }
654 
659  [CLSCompliant(false)]
660  [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
661  [NonVersionable]
662  [__DynamicallyInvokable]
663  public static uint Max(uint val1, uint val2)
664  {
665  if (val1 < val2)
666  {
667  return val2;
668  }
669  return val1;
670  }
671 
676  [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
677  [NonVersionable]
678  [__DynamicallyInvokable]
679  public static long Max(long val1, long val2)
680  {
681  if (val1 < val2)
682  {
683  return val2;
684  }
685  return val1;
686  }
687 
692  [CLSCompliant(false)]
693  [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
694  [NonVersionable]
695  [__DynamicallyInvokable]
696  public static ulong Max(ulong val1, ulong val2)
697  {
698  if (val1 < val2)
699  {
700  return val2;
701  }
702  return val1;
703  }
704 
709  [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
710  [__DynamicallyInvokable]
711  public static float Max(float val1, float val2)
712  {
713  if (val1 > val2)
714  {
715  return val1;
716  }
717  if (float.IsNaN(val1))
718  {
719  return val1;
720  }
721  return val2;
722  }
723 
728  [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
729  [__DynamicallyInvokable]
730  public static double Max(double val1, double val2)
731  {
732  if (val1 > val2)
733  {
734  return val1;
735  }
736  if (double.IsNaN(val1))
737  {
738  return val1;
739  }
740  return val2;
741  }
742 
747  [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
748  [__DynamicallyInvokable]
749  public static decimal Max(decimal val1, decimal val2)
750  {
751  return decimal.Max(val1, val2);
752  }
753 
758  [CLSCompliant(false)]
759  [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
760  [NonVersionable]
761  [__DynamicallyInvokable]
762  public static sbyte Min(sbyte val1, sbyte val2)
763  {
764  if (val1 > val2)
765  {
766  return val2;
767  }
768  return val1;
769  }
770 
775  [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
776  [NonVersionable]
777  [__DynamicallyInvokable]
778  public static byte Min(byte val1, byte val2)
779  {
780  if (val1 > val2)
781  {
782  return val2;
783  }
784  return val1;
785  }
786 
791  [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
792  [NonVersionable]
793  [__DynamicallyInvokable]
794  public static short Min(short val1, short val2)
795  {
796  if (val1 > val2)
797  {
798  return val2;
799  }
800  return val1;
801  }
802 
807  [CLSCompliant(false)]
808  [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
809  [NonVersionable]
810  [__DynamicallyInvokable]
811  public static ushort Min(ushort val1, ushort val2)
812  {
813  if (val1 > val2)
814  {
815  return val2;
816  }
817  return val1;
818  }
819 
824  [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
825  [NonVersionable]
826  [__DynamicallyInvokable]
827  public static int Min(int val1, int val2)
828  {
829  if (val1 > val2)
830  {
831  return val2;
832  }
833  return val1;
834  }
835 
840  [CLSCompliant(false)]
841  [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
842  [NonVersionable]
843  [__DynamicallyInvokable]
844  public static uint Min(uint val1, uint val2)
845  {
846  if (val1 > val2)
847  {
848  return val2;
849  }
850  return val1;
851  }
852 
857  [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
858  [NonVersionable]
859  [__DynamicallyInvokable]
860  public static long Min(long val1, long val2)
861  {
862  if (val1 > val2)
863  {
864  return val2;
865  }
866  return val1;
867  }
868 
873  [CLSCompliant(false)]
874  [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
875  [NonVersionable]
876  [__DynamicallyInvokable]
877  public static ulong Min(ulong val1, ulong val2)
878  {
879  if (val1 > val2)
880  {
881  return val2;
882  }
883  return val1;
884  }
885 
890  [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
891  [__DynamicallyInvokable]
892  public static float Min(float val1, float val2)
893  {
894  if (val1 < val2)
895  {
896  return val1;
897  }
898  if (float.IsNaN(val1))
899  {
900  return val1;
901  }
902  return val2;
903  }
904 
909  [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
910  [__DynamicallyInvokable]
911  public static double Min(double val1, double val2)
912  {
913  if (val1 < val2)
914  {
915  return val1;
916  }
917  if (double.IsNaN(val1))
918  {
919  return val1;
920  }
921  return val2;
922  }
923 
928  [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
929  [__DynamicallyInvokable]
930  public static decimal Min(decimal val1, decimal val2)
931  {
932  return decimal.Min(val1, val2);
933  }
934 
968  [__DynamicallyInvokable]
969  public static double Log(double a, double newBase)
970  {
971  if (double.IsNaN(a))
972  {
973  return a;
974  }
975  if (double.IsNaN(newBase))
976  {
977  return newBase;
978  }
979  if (newBase == 1.0)
980  {
981  return double.NaN;
982  }
983  if (a != 1.0 && (newBase == 0.0 || double.IsPositiveInfinity(newBase)))
984  {
985  return double.NaN;
986  }
987  return Log(a) / Log(newBase);
988  }
989 
996  [CLSCompliant(false)]
997  [__DynamicallyInvokable]
998  public static int Sign(sbyte value)
999  {
1000  if (value < 0)
1001  {
1002  return -1;
1003  }
1004  if (value > 0)
1005  {
1006  return 1;
1007  }
1008  return 0;
1009  }
1010 
1017  [__DynamicallyInvokable]
1018  public static int Sign(short value)
1019  {
1020  if (value < 0)
1021  {
1022  return -1;
1023  }
1024  if (value > 0)
1025  {
1026  return 1;
1027  }
1028  return 0;
1029  }
1030 
1037  [__DynamicallyInvokable]
1038  public static int Sign(int value)
1039  {
1040  if (value < 0)
1041  {
1042  return -1;
1043  }
1044  if (value > 0)
1045  {
1046  return 1;
1047  }
1048  return 0;
1049  }
1050 
1057  [__DynamicallyInvokable]
1058  public static int Sign(long value)
1059  {
1060  if (value < 0)
1061  {
1062  return -1;
1063  }
1064  if (value > 0)
1065  {
1066  return 1;
1067  }
1068  return 0;
1069  }
1070 
1079  [__DynamicallyInvokable]
1080  public static int Sign(float value)
1081  {
1082  if (value < 0f)
1083  {
1084  return -1;
1085  }
1086  if (value > 0f)
1087  {
1088  return 1;
1089  }
1090  if (value == 0f)
1091  {
1092  return 0;
1093  }
1094  throw new ArithmeticException(Environment.GetResourceString("Arithmetic_NaN"));
1095  }
1096 
1105  [__DynamicallyInvokable]
1106  public static int Sign(double value)
1107  {
1108  if (value < 0.0)
1109  {
1110  return -1;
1111  }
1112  if (value > 0.0)
1113  {
1114  return 1;
1115  }
1116  if (value == 0.0)
1117  {
1118  return 0;
1119  }
1120  throw new ArithmeticException(Environment.GetResourceString("Arithmetic_NaN"));
1121  }
1122 
1129  [__DynamicallyInvokable]
1130  public static int Sign(decimal value)
1131  {
1132  if (value < decimal.Zero)
1133  {
1134  return -1;
1135  }
1136  if (value > decimal.Zero)
1137  {
1138  return 1;
1139  }
1140  return 0;
1141  }
1142 
1147  public static long BigMul(int a, int b)
1148  {
1149  return (long)a * (long)b;
1150  }
1151 
1159  public static int DivRem(int a, int b, out int result)
1160  {
1161  result = a % b;
1162  return a / b;
1163  }
1164 
1172  public static long DivRem(long a, long b, out long result)
1173  {
1174  result = a % b;
1175  return a / b;
1176  }
1177  }
1178 }
static decimal Floor(decimal d)
Returns the largest integer less than or equal to the specified decimal number.
Definition: Math.cs:119
static double Round(double value, int digits, MidpointRounding mode)
Rounds a double-precision floating-point value to a specified number of fractional digits....
Definition: Math.cs:241
static decimal Round(decimal d, MidpointRounding mode)
Rounds a decimal value to the nearest integer. A parameter specifies how to round the value if it is ...
Definition: Math.cs:285
static decimal Round(decimal d, int decimals, MidpointRounding mode)
Rounds a decimal value to a specified number of fractional digits. A parameter specifies how to round...
Definition: Math.cs:301
static int Sign(short value)
Returns an integer that indicates the sign of a 16-bit signed integer.
Definition: Math.cs:1018
static double Min(double val1, double val2)
Returns the smaller of two double-precision floating-point numbers.
Definition: Math.cs:911
static long Min(long val1, long val2)
Returns the smaller of two 64-bit signed integers.
Definition: Math.cs:860
static uint Min(uint val1, uint val2)
Returns the smaller of two 32-bit unsigned integers.
Definition: Math.cs:844
static double Sin(double a)
Returns the sine of the specified angle.
const double E
Represents the natural logarithmic base, specified by the constant, e.
Definition: Math.cs:42
static double Log10(double d)
Returns the base 10 logarithm of a specified number.
static byte Min(byte val1, byte val2)
Returns the smaller of two 8-bit unsigned integers.
Definition: Math.cs:778
static double Atan2(double y, double x)
Returns the angle whose tangent is the quotient of two specified numbers.
static sbyte Min(sbyte val1, sbyte val2)
Returns the smaller of two 8-bit signed integers.
Definition: Math.cs:762
Definition: __Canon.cs:3
static float Max(float val1, float val2)
Returns the larger of two single-precision floating-point numbers.
Definition: Math.cs:711
The exception that is thrown when the value of an argument is outside the allowable range of values a...
static decimal Round(decimal d)
Rounds a decimal value to the nearest integral value.
Definition: Math.cs:259
static double Acos(double d)
Returns the angle whose cosine is the specified number.
static double Pow(double x, double y)
Returns a specified number raised to the specified power.
static uint Max(uint val1, uint val2)
Returns the larger of two 32-bit unsigned integers.
Definition: Math.cs:663
static double Atan(double d)
Returns the angle whose tangent is the specified number.
static int DivRem(int a, int b, out int result)
Calculates the quotient of two 32-bit signed integers and also returns the remainder in an output par...
Definition: Math.cs:1159
static decimal Max(decimal val1, decimal val2)
Returns the larger of two decimal numbers.
Definition: Math.cs:749
The exception that is thrown when an arithmetic, casting, or conversion operation in a checked contex...
Cer
Specifies a method's behavior when called within a constrained execution region.
Definition: Cer.cs:5
static short Max(short val1, short val2)
Returns the larger of two 16-bit signed integers.
Definition: Math.cs:613
static ulong Max(ulong val1, ulong val2)
Returns the larger of two 64-bit unsigned integers.
Definition: Math.cs:696
Provides information about, and means to manipulate, the current environment and platform....
Definition: Environment.cs:21
const double PI
Represents the ratio of the circumference of a circle to its diameter, specified by the constant,...
Definition: Math.cs:38
static double Truncate(double d)
Calculates the integral part of a specified double-precision floating-point number.
Definition: Math.cs:337
static long Abs(long value)
Returns the absolute value of a 64-bit signed integer.
Definition: Math.cs:530
static double Tanh(double value)
Returns the hyperbolic tangent of the specified angle.
static byte Max(byte val1, byte val2)
Returns the larger of two 8-bit unsigned integers.
Definition: Math.cs:597
static int Min(int val1, int val2)
Returns the smaller of two 32-bit signed integers.
Definition: Math.cs:827
static double Tan(double a)
Returns the tangent of the specified angle.
static sbyte Max(sbyte val1, sbyte val2)
Returns the larger of two 8-bit signed integers.
Definition: Math.cs:581
static decimal Abs(decimal value)
Returns the absolute value of a T:System.Decimal number.
Definition: Math.cs:568
static int Sign(int value)
Returns an integer that indicates the sign of a 32-bit signed integer.
Definition: Math.cs:1038
static double Round(double a)
Rounds a double-precision floating-point value to the nearest integral value.
static double Cosh(double value)
Returns the hyperbolic cosine of the specified angle.
MidpointRounding
Specifies how mathematical rounding methods should process a number that is midway between two number...
static short Min(short val1, short val2)
Returns the smaller of two 16-bit signed integers.
Definition: Math.cs:794
static double Log(double d)
Returns the natural (base e) logarithm of a specified number.
static double Sqrt(double d)
Returns the square root of a specified number.
MethodImplOptions
Defines the details of how a method is implemented.
static double Exp(double d)
Returns e raised to the specified power.
static int Max(int val1, int val2)
Returns the larger of two 32-bit signed integers.
Definition: Math.cs:646
static double Log(double a, double newBase)
Returns the logarithm of a specified number in a specified base.
Definition: Math.cs:969
static double Cos(double d)
Returns the cosine of the specified angle.
static int Sign(long value)
Returns an integer that indicates the sign of a 64-bit signed integer.
Definition: Math.cs:1058
The exception that is thrown when one of the arguments provided to a method is not valid.
static int Sign(decimal value)
Returns an integer that indicates the sign of a decimal number.
Definition: Math.cs:1130
static double Max(double val1, double val2)
Returns the larger of two double-precision floating-point numbers.
Definition: Math.cs:730
static sbyte Abs(sbyte value)
Returns the absolute value of an 8-bit signed integer.
Definition: Math.cs:458
static double Asin(double d)
Returns the angle whose sine is the specified number.
static decimal Round(decimal d, int decimals)
Rounds a decimal value to a specified number of fractional digits.
Definition: Math.cs:272
static decimal Truncate(decimal d)
Calculates the integral part of a specified decimal number.
Definition: Math.cs:314
static decimal Min(decimal val1, decimal val2)
Returns the smaller of two decimal numbers.
Definition: Math.cs:930
static double IEEERemainder(double x, double y)
Returns the remainder resulting from the division of a specified number by another specified number.
Definition: Math.cs:414
static int Sign(float value)
Returns an integer that indicates the sign of a single-precision floating-point number.
Definition: Math.cs:1080
static long DivRem(long a, long b, out long result)
Calculates the quotient of two 64-bit signed integers and also returns the remainder in an output par...
Definition: Math.cs:1172
Consistency
Specifies a reliability contract.
Definition: Consistency.cs:5
static long Max(long val1, long val2)
Returns the larger of two 64-bit signed integers.
Definition: Math.cs:679
static short Abs(short value)
Returns the absolute value of a 16-bit signed integer.
Definition: Math.cs:482
static ulong Min(ulong val1, ulong val2)
Returns the smaller of two 64-bit unsigned integers.
Definition: Math.cs:877
static double Round(double value, MidpointRounding mode)
Rounds a double-precision floating-point value to the nearest integer. A parameter specifies how to r...
Definition: Math.cs:226
static ushort Max(ushort val1, ushort val2)
Returns the larger of two 16-bit unsigned integers.
Definition: Math.cs:630
Provides constants and static methods for trigonometric, logarithmic, and other common mathematical f...
Definition: Math.cs:10
static int Abs(int value)
Returns the absolute value of a 32-bit signed integer.
Definition: Math.cs:506
The exception that is thrown for errors in an arithmetic, casting, or conversion operation.
static int Sign(double value)
Returns an integer that indicates the sign of a double-precision floating-point number.
Definition: Math.cs:1106
static ushort Min(ushort val1, ushort val2)
Returns the smaller of two 16-bit unsigned integers.
Definition: Math.cs:811
static int Sign(sbyte value)
Returns an integer that indicates the sign of an 8-bit signed integer.
Definition: Math.cs:998
static double Round(double value, int digits)
Rounds a double-precision floating-point value to a specified number of fractional digits.
Definition: Math.cs:210
static decimal Ceiling(decimal d)
Returns the smallest integral value that is greater than or equal to the specified decimal number.
Definition: Math.cs:86
static float Min(float val1, float val2)
Returns the smaller of two single-precision floating-point numbers.
Definition: Math.cs:892
static long BigMul(int a, int b)
Produces the full product of two 32-bit numbers.
Definition: Math.cs:1147
static double Sinh(double value)
Returns the hyperbolic sine of the specified angle.