9 [__DynamicallyInvokable]
12 private static double doubleRoundLimit = 1
E+16;
14 private const int maxRoundingDigits = 15;
16 private static double[] roundPower10Double =
new double[16]
37 [__DynamicallyInvokable]
38 public const double PI = 3.1415926535897931;
41 [__DynamicallyInvokable]
42 public const double E = 2.7182818284590451;
49 [SecuritySafeCritical]
50 [__DynamicallyInvokable]
51 public static extern double Acos(
double d);
58 [SecuritySafeCritical]
59 [__DynamicallyInvokable]
60 public static extern double Asin(
double d);
67 [SecuritySafeCritical]
68 [__DynamicallyInvokable]
69 public static extern double Atan(
double d);
78 [SecuritySafeCritical]
79 [__DynamicallyInvokable]
80 public static extern double Atan2(
double y,
double x);
85 [__DynamicallyInvokable]
88 return decimal.Ceiling(d);
95 [SecuritySafeCritical]
96 [__DynamicallyInvokable]
97 public static extern double Ceiling(
double a);
103 [SecuritySafeCritical]
104 [__DynamicallyInvokable]
105 public static extern double Cos(
double d);
111 [SecuritySafeCritical]
112 [__DynamicallyInvokable]
113 public static extern double Cosh(
double value);
118 [__DynamicallyInvokable]
119 public static decimal
Floor(decimal d)
121 return decimal.Floor(d);
128 [SecuritySafeCritical]
129 [__DynamicallyInvokable]
130 public static extern double Floor(
double d);
132 [SecuritySafeCritical]
133 private unsafe
static double InternalRound(
double value,
int digits,
MidpointRounding mode)
135 if (
Abs(value) < doubleRoundLimit)
137 double num = roundPower10Double[digits];
141 double value2 = SplitFractionDouble(&value);
142 if (
Abs(value2) >= 0.5)
144 value += (double)
Sign(value2);
149 value =
Round(value);
156 [SecuritySafeCritical]
157 private unsafe
static double InternalTruncate(
double d)
159 SplitFractionDouble(&d);
167 [SecuritySafeCritical]
168 [__DynamicallyInvokable]
169 public static extern double Sin(
double a);
175 [SecuritySafeCritical]
176 [__DynamicallyInvokable]
177 public static extern double Tan(
double a);
183 [SecuritySafeCritical]
184 [__DynamicallyInvokable]
185 public static extern double Sinh(
double value);
191 [SecuritySafeCritical]
192 [__DynamicallyInvokable]
193 public static extern double Tanh(
double value);
199 [SecuritySafeCritical]
200 [__DynamicallyInvokable]
201 public static extern double Round(
double a);
209 [__DynamicallyInvokable]
210 public static double Round(
double value,
int digits)
212 if (digits < 0 || digits > 15)
225 [__DynamicallyInvokable]
228 return Round(value, 0, mode);
240 [__DynamicallyInvokable]
243 if (digits < 0 || digits > 15)
251 return InternalRound(value, digits, mode);
258 [__DynamicallyInvokable]
259 public static decimal
Round(decimal d)
261 return decimal.Round(d, 0);
271 [__DynamicallyInvokable]
272 public static decimal
Round(decimal d,
int decimals)
274 return decimal.Round(d, decimals);
284 [__DynamicallyInvokable]
287 return decimal.Round(d, 0, mode);
300 [__DynamicallyInvokable]
303 return decimal.Round(d, decimals, mode);
308 private unsafe
static extern double SplitFractionDouble(
double* value);
313 [__DynamicallyInvokable]
316 return decimal.Truncate(d);
336 [__DynamicallyInvokable]
339 return InternalTruncate(d);
353 [SecuritySafeCritical]
354 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
355 [__DynamicallyInvokable]
356 public static extern double Sqrt(
double d);
371 [SecuritySafeCritical]
372 [__DynamicallyInvokable]
373 public static extern double Log(
double d);
388 [SecuritySafeCritical]
389 [__DynamicallyInvokable]
390 public static extern double Log10(
double d);
396 [SecuritySafeCritical]
397 [__DynamicallyInvokable]
398 public static extern double Exp(
double d);
405 [SecuritySafeCritical]
406 [__DynamicallyInvokable]
407 public static extern double Pow(
double x,
double y);
413 [__DynamicallyInvokable]
425 if (
double.IsNaN(num))
429 if (num == 0.0 &&
double.IsNegative(x))
431 return double.NegativeZero;
433 double num2 = num -
Abs(y) * (double)
Sign(x);
434 if (
Abs(num2) ==
Abs(num))
437 double value =
Round(num3);
438 if (
Abs(value) >
Abs(num3))
456 [CLSCompliant(
false)]
457 [__DynamicallyInvokable]
458 public static sbyte
Abs(sbyte value)
464 return AbsHelper(value);
467 private static sbyte AbsHelper(sbyte value)
469 if (value == sbyte.MinValue)
473 return (sbyte)(-value);
481 [__DynamicallyInvokable]
482 public static short Abs(
short value)
488 return AbsHelper(value);
491 private static short AbsHelper(
short value)
493 if (value ==
short.MinValue)
497 return (
short)(-value);
505 [__DynamicallyInvokable]
506 public static int Abs(
int value)
512 return AbsHelper(value);
515 private static int AbsHelper(
int value)
517 if (value ==
int.MinValue)
529 [__DynamicallyInvokable]
530 public static long Abs(
long value)
536 return AbsHelper(value);
539 private static long AbsHelper(
long value)
541 if (value ==
long.MinValue)
552 [SecuritySafeCritical]
553 [__DynamicallyInvokable]
554 public static extern float Abs(
float value);
560 [SecuritySafeCritical]
561 [__DynamicallyInvokable]
562 public static extern double Abs(
double value);
567 [__DynamicallyInvokable]
568 public static decimal
Abs(decimal value)
570 return decimal.Abs(value);
577 [CLSCompliant(
false)]
578 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
580 [__DynamicallyInvokable]
581 public static sbyte
Max(sbyte val1, sbyte val2)
594 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
596 [__DynamicallyInvokable]
597 public static byte Max(
byte val1,
byte val2)
610 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
612 [__DynamicallyInvokable]
613 public static short Max(
short val1,
short val2)
626 [CLSCompliant(
false)]
627 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
629 [__DynamicallyInvokable]
630 public static ushort
Max(ushort val1, ushort val2)
643 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
645 [__DynamicallyInvokable]
646 public static int Max(
int val1,
int val2)
659 [CLSCompliant(
false)]
660 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
662 [__DynamicallyInvokable]
663 public static uint
Max(uint val1, uint val2)
676 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
678 [__DynamicallyInvokable]
679 public static long Max(
long val1,
long val2)
692 [CLSCompliant(
false)]
693 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
695 [__DynamicallyInvokable]
696 public static ulong
Max(ulong val1, ulong val2)
709 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
710 [__DynamicallyInvokable]
711 public static float Max(
float val1,
float val2)
717 if (
float.IsNaN(val1))
728 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
729 [__DynamicallyInvokable]
730 public static double Max(
double val1,
double val2)
736 if (
double.IsNaN(val1))
747 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
748 [__DynamicallyInvokable]
749 public static decimal
Max(decimal val1, decimal val2)
751 return decimal.Max(val1, val2);
758 [CLSCompliant(
false)]
759 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
761 [__DynamicallyInvokable]
762 public static sbyte
Min(sbyte val1, sbyte val2)
775 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
777 [__DynamicallyInvokable]
778 public static byte Min(
byte val1,
byte val2)
791 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
793 [__DynamicallyInvokable]
794 public static short Min(
short val1,
short val2)
807 [CLSCompliant(
false)]
808 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
810 [__DynamicallyInvokable]
811 public static ushort
Min(ushort val1, ushort val2)
824 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
826 [__DynamicallyInvokable]
827 public static int Min(
int val1,
int val2)
840 [CLSCompliant(
false)]
841 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
843 [__DynamicallyInvokable]
844 public static uint
Min(uint val1, uint val2)
857 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
859 [__DynamicallyInvokable]
860 public static long Min(
long val1,
long val2)
873 [CLSCompliant(
false)]
874 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
876 [__DynamicallyInvokable]
877 public static ulong
Min(ulong val1, ulong val2)
890 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
891 [__DynamicallyInvokable]
892 public static float Min(
float val1,
float val2)
898 if (
float.IsNaN(val1))
909 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
910 [__DynamicallyInvokable]
911 public static double Min(
double val1,
double val2)
917 if (
double.IsNaN(val1))
928 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
929 [__DynamicallyInvokable]
930 public static decimal
Min(decimal val1, decimal val2)
932 return decimal.Min(val1, val2);
968 [__DynamicallyInvokable]
969 public static double Log(
double a,
double newBase)
975 if (
double.IsNaN(newBase))
983 if (a != 1.0 && (newBase == 0.0 ||
double.IsPositiveInfinity(newBase)))
987 return Log(a) /
Log(newBase);
996 [CLSCompliant(
false)]
997 [__DynamicallyInvokable]
998 public static int Sign(sbyte value)
1017 [__DynamicallyInvokable]
1018 public static int Sign(
short value)
1037 [__DynamicallyInvokable]
1057 [__DynamicallyInvokable]
1079 [__DynamicallyInvokable]
1080 public static int Sign(
float value)
1105 [__DynamicallyInvokable]
1106 public static int Sign(
double value)
1129 [__DynamicallyInvokable]
1130 public static int Sign(decimal value)
1132 if (value < decimal.Zero)
1136 if (value > decimal.Zero)
1149 return (
long)a * (long)b;
1159 public static int DivRem(
int a,
int b, out
int result)
1172 public static long DivRem(
long a,
long b, out
long result)
static decimal Floor(decimal d)
Returns the largest integer less than or equal to the specified decimal number.
static double Round(double value, int digits, MidpointRounding mode)
Rounds a double-precision floating-point value to a specified number of fractional digits....
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 ...
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...
static int Sign(short value)
Returns an integer that indicates the sign of a 16-bit signed integer.
static double Min(double val1, double val2)
Returns the smaller of two double-precision floating-point numbers.
static long Min(long val1, long val2)
Returns the smaller of two 64-bit signed integers.
static uint Min(uint val1, uint val2)
Returns the smaller of two 32-bit unsigned integers.
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.
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.
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.
static float Max(float val1, float val2)
Returns the larger of two single-precision floating-point numbers.
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.
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.
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...
static decimal Max(decimal val1, decimal val2)
Returns the larger of two decimal numbers.
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.
static short Max(short val1, short val2)
Returns the larger of two 16-bit signed integers.
static ulong Max(ulong val1, ulong val2)
Returns the larger of two 64-bit unsigned integers.
Provides information about, and means to manipulate, the current environment and platform....
const double PI
Represents the ratio of the circumference of a circle to its diameter, specified by the constant,...
static double Truncate(double d)
Calculates the integral part of a specified double-precision floating-point number.
static long Abs(long value)
Returns the absolute value of a 64-bit signed integer.
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.
static int Min(int val1, int val2)
Returns the smaller of two 32-bit signed integers.
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.
static decimal Abs(decimal value)
Returns the absolute value of a T:System.Decimal number.
static int Sign(int value)
Returns an integer that indicates the sign of a 32-bit signed integer.
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.
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.
static double Log(double a, double newBase)
Returns the logarithm of a specified number in a specified base.
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.
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.
static double Max(double val1, double val2)
Returns the larger of two double-precision floating-point numbers.
static sbyte Abs(sbyte value)
Returns the absolute value of an 8-bit signed integer.
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.
static decimal Truncate(decimal d)
Calculates the integral part of a specified decimal number.
static decimal Min(decimal val1, decimal val2)
Returns the smaller of two decimal numbers.
static double IEEERemainder(double x, double y)
Returns the remainder resulting from the division of a specified number by another specified number.
static int Sign(float value)
Returns an integer that indicates the sign of a single-precision floating-point number.
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...
Consistency
Specifies a reliability contract.
static long Max(long val1, long val2)
Returns the larger of two 64-bit signed integers.
static short Abs(short value)
Returns the absolute value of a 16-bit signed integer.
static ulong Min(ulong val1, ulong val2)
Returns the smaller of two 64-bit unsigned integers.
static double Round(double value, MidpointRounding mode)
Rounds a double-precision floating-point value to the nearest integer. A parameter specifies how to r...
static ushort Max(ushort val1, ushort val2)
Returns the larger of two 16-bit unsigned integers.
Provides constants and static methods for trigonometric, logarithmic, and other common mathematical f...
static int Abs(int value)
Returns the absolute value of a 32-bit signed integer.
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.
static ushort Min(ushort val1, ushort val2)
Returns the smaller of two 16-bit unsigned integers.
static int Sign(sbyte value)
Returns an integer that indicates the sign of an 8-bit signed integer.
static double Round(double value, int digits)
Rounds a double-precision floating-point value to a specified number of fractional digits.
static decimal Ceiling(decimal d)
Returns the smallest integral value that is greater than or equal to the specified decimal number.
static float Min(float val1, float val2)
Returns the smaller of two single-precision floating-point numbers.
static long BigMul(int a, int b)
Produces the full product of two 32-bit numbers.
static double Sinh(double value)
Returns the hyperbolic sine of the specified angle.