System.Math Class

Assembly: Mscorlib.dll
Namespace: System
Summary
Provides constants and static methods for trigonometric, logarithmic, and other common mathematical functions.
C# Syntax:
public sealed class Math
See also:
System Namespace

System.Math Member List:

Public Fields
E Represents the natural logarithmic base, specified by the constant, e.
PI Represents the ratio of the circumference of a circle to its diameter, specified by the constant, (pi).
Public Methods
Abs Overloaded:
Abs(decimal value)

Returns the absolute value of a Decimal number.
Abs Overloaded:
Abs(double value)

Returns the absolute value of a double-precision floating-point number.
Abs Overloaded:
Abs(short value)

Returns the absolute value of a 16-bit signed integer.
Abs Overloaded:
Abs(int value)

Returns the absolute value of a 32-bit signed integer.
Abs Overloaded:
Abs(long value)

Returns the absolute value of a 64-bit signed integer.
Abs Overloaded:
Abs(sbyte value)

Returns the absolute value of an 8-bit signed integer.
Abs Overloaded:
Abs(float value)

Returns the absolute value of a single-precision floating-point number.
Acos Returns the angle whose cosine is the specified number.
Asin Returns the angle whose sine is the specified number.
Atan Returns the angle whose tangent is the specified number.
Atan2 Returns the angle whose tangent is the quotient of two specified numbers.
Ceiling Returns the smallest whole number greater than or equal to the specified number.
Cos Returns the cosine of the specified angle.
Cosh Returns the hyperbolic cosine of the specified angle.
Equals
(inherited from System.Object)
See base class member description: System.Object.Equals

Derived from System.Object, the primary base class for all objects.
Exp Returns e raised to the specified power.
Floor Returns the largest whole number less than or equal to the specified number.
GetHashCode
(inherited from System.Object)
See base class member description: System.Object.GetHashCode

Derived from System.Object, the primary base class for all objects.
GetType
(inherited from System.Object)
See base class member description: System.Object.GetType

Derived from System.Object, the primary base class for all objects.
IEEERemainder Returns the remainder resulting from the division of a specified number by another specified number.
Log Overloaded:
Log(double d)

Returns the natural (base e) logarithm of a specified number.
Log Overloaded:
Log(double a, double newBase)

Returns the logarithm of a specified number in a specified base.
Log10 Returns the base 10 logarithm of a specified number.
Max Overloaded:
Max(byte val1, byte val2)

Returns the larger of two 8-bit unsigned integers.
Max Overloaded:
Max(decimal val1, decimal val2)

Returns the larger of two decimal numbers.
Max Overloaded:
Max(double val1, double val2)

Returns the larger of two double-precision floating-point numbers.
Max Overloaded:
Max(short val1, short val2)

Returns the larger of two 16-bit signed integers.
Max Overloaded:
Max(int val1, int val2)

Returns the larger of two 32-bit signed integers.
Max Overloaded:
Max(long val1, long val2)

Returns the larger of two 64-bit signed integers.
Max Overloaded:
Max(sbyte val1, sbyte val2)

Returns the larger of two 8-bit signed integers.
Max Overloaded:
Max(float val1, float val2)

Returns the larger of two single-precision floating-point numbers.
Max Overloaded:
Max(ushort val1, ushort val2)

Returns the larger of two 16-bit unsigned integers.
Max Overloaded:
Max(uint val1, uint val2)

Returns the larger of two 32-bit unsigned integers.
Max Overloaded:
Max(ulong val1, ulong val2)

Returns the larger of two 64-bit unsigned integers.
Min Overloaded:
Min(byte val1, byte val2)

Returns the smaller of two 8-bit unsigned integers.
Min Overloaded:
Min(decimal val1, decimal val2)

Returns the smaller of two decimal numbers.
Min Overloaded:
Min(double val1, double val2)

Returns the smaller of two double-precision floating-point numbers.
Min Overloaded:
Min(short val1, short val2)

Returns the smaller of two 16-bit signed integers.
Min Overloaded:
Min(int val1, int val2)

Returns the smaller of two 32-bit signed integers.
Min Overloaded:
Min(long val1, long val2)

Returns the smaller of two 64-bit signed integers.
Min Overloaded:
Min(sbyte val1, sbyte val2)

Returns the smaller of two 8-bit signed integers.
Min Overloaded:
Min(float val1, float val2)

Returns the smaller of two single-precision floating-point numbers.
Min Overloaded:
Min(ushort val1, ushort val2)

Returns the smaller of two 16-bit unsigned integers.
Min Overloaded:
Min(uint val1, uint val2)

Returns the smaller of two 32-bit unsigned integers.
Min Overloaded:
Min(ulong val1, ulong val2)

Returns the smaller of two 64-bit unsigned integers.
Pow Returns a specified number raised to the specified power.
Round Overloaded:
Round(decimal d)

Returns the whole number nearest the specified value.
Round Overloaded:
Round(double a)

Returns the whole number nearest the specified value.
Round Overloaded:
Round(decimal d, int decimals)

Returns the number with the specified precision nearest the specified value.
Round Overloaded:
Round(double value, int digits)

Returns the number with the specified precision nearest the specified value.
Sign Overloaded:
Sign(decimal value)

Returns a value indicating the sign of a decimal number.
Sign Overloaded:
Sign(double value)

Returns a value indicating the sign of a double-precision floating-point number.
Sign Overloaded:
Sign(short value)

Returns a value indicating the sign of a 16-bit signed integer.
Sign Overloaded:
Sign(int value)

Returns a value indicating the sign of a 32-bit signed integer.
Sign Overloaded:
Sign(long value)

Returns a value indicating the sign of a 64-bit signed integer.
Sign Overloaded:
Sign(sbyte value)

Returns a value indicating the sign of an 8-bit signed integer.
Sign Overloaded:
Sign(float value)

Returns a value indicating the sign of a single-precision floating-point number.
Sin Returns the sine of the specified angle.
Sinh Returns the hyperbolic sine of the specified angle.
Sqrt Returns the square root of a specified number.
Tan Returns the tangent of the specified angle.
Tanh Returns the hyperbolic tangent of the specified angle.
ToString
(inherited from System.Object)
See base class member description: System.Object.ToString

Derived from System.Object, the primary base class for all objects.
Protected Methods
Finalize
(inherited from System.Object)
See base class member description: System.Object.Finalize

Derived from System.Object, the primary base class for all objects.
MemberwiseClone
(inherited from System.Object)
See base class member description: System.Object.MemberwiseClone

Derived from System.Object, the primary base class for all objects.

Hierarchy:


System.Math Member Details

Field: E
Summary
Represents the natural logarithmic base, specified by the constant, e.
C# Syntax:
public const double E;
Remarks
The value of this field is 2.7182818284590452354.

Return to top


Field: PI
Summary
Represents the ratio of the circumference of a circle to its diameter, specified by the constant, (pi).
C# Syntax:
public const double PI;
Remarks
The value of this field is 3.14159265358979323846.

Return to top


Overloaded Method: Abs(
   decimal value
)
Summary
Returns the absolute value of a Decimal number.
C# Syntax:
public static decimal Abs(
   decimal value
);
Parameters:

value

A number in the range Decimal.MinValue (<=) value (<=) Decimal.MaxValue. A number in the range Decimal.MinValue (<=) value (<=) Decimal.MaxValue.

Return Value:
A Decimal, x, such that 0 (<=) x (<=) Decimal.MaxValue.

Return to top


Overloaded Method: Abs(
   double value
)
Summary
Returns the absolute value of a double-precision floating-point number.
C# Syntax:
public static double Abs(
   double value
);
Parameters:

value

A number in the range Double.MinValue < value (<=) Double.MaxValue.

Return Value:
A double-precision floating-point number, x, such that 0 (<=) x (<=) Double.MaxValue.
Remarks
If value is equal to Double.NegativeInfinity or Double.PositiveInfinity, the return value is Double.PositiveInfinity. If value is equal to Double.NaN, the return value is Double.NaN.

Return to top


Overloaded Method: Abs(
   short value
)
Summary
Returns the absolute value of a 16-bit signed integer.
C# Syntax:
public static short Abs(
   short value
);
Parameters:

value

A number in the range Int16.MinValue < value (<=) Int16.MaxValue.

Return Value:
A 16-bit signed integer, x, such that 0 (<=) x (<=) Int16.MaxValue.
Exceptions
Exception Type Condition
OverflowException value equals Int16.MinValue.

Return to top


Overloaded Method: Abs(
   int value
)
Summary
Returns the absolute value of a 32-bit signed integer.
C# Syntax:
public static int Abs(
   int value
);
Parameters:

value

A number in the range Int32.MinValue < value (<=) Int32.MaxValue.

Return Value:
A 32-bit signed integer, x, such that 0 (<=) x (<=) Int32.MaxValue.
Exceptions
Exception Type Condition
OverflowException value equals Int32.MinValue.

Return to top


Overloaded Method: Abs(
   long value
)
Summary
Returns the absolute value of a 64-bit signed integer.
C# Syntax:
public static long Abs(
   long value
);
Parameters:

value

A number in the range Int64.MinValue < value (<=) Int64.MaxValue.

Return Value:
A 64-bit signed integer, x, such that 0 (<=) x (<=) Int64.MaxValue.
Exceptions
Exception Type Condition
OverflowException value equals Int64.MinValue.

Return to top


Overloaded Method: Abs(
   sbyte value
)
Summary
Returns the absolute value of an 8-bit signed integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static sbyte Abs(
   sbyte value
);
Parameters:

value

A number in the range SByte.MinValue < value (<=) SByte.MaxValue.

Return Value:
An 8-bit signed integer, x, such that 0 (<=) x (<=) SByte.MaxValue.
Exceptions
Exception Type Condition
OverflowException value equals SByte.MinValue.

Return to top


Overloaded Method: Abs(
   float value
)
Summary
Returns the absolute value of a single-precision floating-point number.
C# Syntax:
public static float Abs(
   float value
);
Parameters:

value

A number in the range Single.MinValue < value (<=) Single.MaxValue.

Return Value:
A single-precision floating-point number, x, such that 0 (<=) x (<=) Single.MaxValue.
Remarks
If value is equal to Single.NegativeInfinity or Single.PositiveInfinity, the return value is Single.PositiveInfinity. If value is equal to Single.NaN, the return value is Single.NaN.

Return to top


Method: Acos(
   double d
)
Summary
Returns the angle whose cosine is the specified number.
C# Syntax:
public static double Acos(
   double d
);
Parameters:

d

A number representing a cosine, where -1 (<=) d (<=) 1.

Return Value:
An angle, q, measured in radians, such that 0 (<=) q (<= ) (pi)

-or-

Double.NaN if d < -1 or d > 1.

Remarks
Multiply the return value by 180/(pi) to convert from radians to degrees.

Return to top


Method: Asin(
   double d
)
Summary
Returns the angle whose sine is the specified number.
C# Syntax:
public static double Asin(
   double d
);
Parameters:

d

A number representing a sine, where -1 (<=) d (<=) 1.

Return Value:
An angle, q, measured in radians, such that -(pi)/2 (<=) q (<=) (pi)/2

-or-

Double.NaN if d < -1 or d > 1.

Remarks
A positive return value represents a counterclockwise angle from the x-axis; a negative return value represents a clockwise angle.

Multiply the return value by 180/(pi) to convert from radians to degrees.

Return to top


Method: Atan(
   double d
)
Summary
Returns the angle whose tangent is the specified number.
C# Syntax:
public static double Atan(
   double d
);
Parameters:

d

A number representing a tangent.

Return Value:
An angle, q, measured in radians, such that -(pi)/2 (<=) q (<= ) (pi)/2.

-or-

Double.NaN if d equals Double.NaN, -(pi)/2 rounded to double precision (-1.5707963267949) if d equals Double.NegativeInfinity, or (pi)/2 rounded to double precision (1.5707963267949) if d equals Double.PositiveInfinity.

Remarks
A positive return value represents a counterclockwise angle from the x-axis; a negative return value represents a clockwise angle.

Multiply the return value by 180/(pi) to convert from radians to degrees.

Return to top


Method: Atan2(
   double y,
   double x
)
Summary
Returns the angle whose tangent is the quotient of two specified numbers.
C# Syntax:
public static double Atan2(
   double y,
   double x
);
Parameters:

y

The y coordinate of a point.

x

The x coordinate of a point.

Return Value:
An angle, q, measured in radians, such that -(pi) < q (<=) (pi), and tan(q) = y / x, where (x, y) is a point in the Cartesian plane. Observe the following:
Remarks
The return value is the angle in the Cartesian plane formed by the x-axis, and a vector starting from the origin, (0,0), and terminating at the point, (x,y).

Return to top


Method: Ceiling(
   double a
)
Summary
Returns the smallest whole number greater than or equal to the specified number.
C# Syntax:
public static double Ceiling(
   double a
);
Parameters:

a

A number.

Return Value:
The smallest whole number greater than or equal to a. If a is equal to Double.NaN, Double.NegativeInfinity, or Double.PositiveInfinity, that value is returned.
Remarks
The behavior of this method follows IEEE Standard 754, section 4. This kind of rounding is sometimes called rounding toward positive infinity.
See also:
Math.Round | Math.Floor

Return to top


Method: Cos(
   double d
)
Summary
Returns the cosine of the specified angle.
C# Syntax:
public static double Cos(
   double d
);
Parameters:

d

An angle, measured in radians.

Return Value:
The cosine of d.
Remarks
The angle, d, must be in radians. Multiply by (pi)/180 to convert degrees to radians.

Return to top


Method: Cosh(
   double value
)
Summary
Returns the hyperbolic cosine of the specified angle.
C# Syntax:
public static double Cosh(
   double value
);
Parameters:

value

An angle, measured in radians.

Return Value:
The hyperbolic cosine of value. If value is equal to Double.NegativeInfinity or Double.PositiveInfinity, Double.PositiveInfinity is returned. If value is equal to Double.NaN, Double.NaN is returned.
Remarks
The angle, value, must be in radians. Multiply by (pi)/180 to convert degrees to radians.

Return to top


Method: Equals(
   object obj
)
Inherited
See base class member description: System.Object.Equals
C# Syntax:
public virtual bool Equals(
   object obj
);

For more information on members inherited from System.Object click on the link above.

Return to top


Method: Exp(
   double d
)
Summary
Returns e raised to the specified power.
C# Syntax:
public static double Exp(
   double d
);
Parameters:

d

A number specifying a power.

Return Value:
The number e raised to the power d. If d equals Double.NaN or Double.PositiveInfinity, that value is returned. If d equals Double.NegativeInfinity, 0 is returned.
Remarks
Use the Math.Pow method to calculate powers of other bases.

Exp is the inverse of Math.Log.

See also:
Math.E | Math.Pow | Math.Log

Return to top


Method: Finalize()
Inherited
See base class member description: System.Object.Finalize
C# Syntax:
~Math();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: Floor(
   double d
)
Summary
Returns the largest whole number less than or equal to the specified number.
C# Syntax:
public static double Floor(
   double d
);
Parameters:

d

A number.

Return Value:
The largest whole number less than or equal to d. If d is equal to Double.NaN, Double.NegativeInfinity, or Double.PositiveInfinity, then that value is returned.
Remarks
The behavior of this method follows IEEE Standard 754, section 4. This kind of rounding is sometimes called rounding toward negative infinity.
See also:
Math.Round | Math.Ceiling

Return to top


Method: GetHashCode()
Inherited
See base class member description: System.Object.GetHashCode
C# Syntax:
public virtual int GetHashCode();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetType()
Inherited
See base class member description: System.Object.GetType
C# Syntax:
public Type GetType();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: IEEERemainder(
   double x,
   double y
)
Summary
Returns the remainder resulting from the division of a specified number by another specified number.
C# Syntax:
public static double IEEERemainder(
   double x,
   double y
);
Parameters:

x

A dividend.

y

A divisor.

Return Value:
A number equal to x - (y Q), where Q is the quotient of x / y rounded to the nearest integer (if x / y falls halfway between two integers, the even integer is returned).

If x - (y Q) is zero, the value +0 is returned if x is positive, or -0 if x is negative.

If y = 0, Double.NaN (Not-A-Number) is returned.

Remarks
This operation complies with the remainder operation defined in Section 5.1 of ANSI/IEEE Std 754-1985; IEEE Standard for Binary Floating-Point Arithmetic; Institute of Electrical and Electronics Engineers, Inc; 1985.

Return to top


Overloaded Method: Log(
   double d
)
Summary
Returns the natural (base e) logarithm of a specified number.
C# Syntax:
public static double Log(
   double d
);
Parameters:

d

A number whose logarithm is to be found.

Return Value:


Sign of Returns
Positive The natural logarithm of ; that is, ln or log
Zero Double.PositiveInfinity
Negative Double.NaN
If d is equal to Double.NaN, returns Double.NaN. If d is equal to Double.PositiveInfinity, returns Double.PositiveInfinity.
Remarks
Parameter d is specified as a base 10 number.
See also:
Math.E | Math.Exp

Return to top


Overloaded Method: Log(
   double a,
   double newBase
)
Summary
Returns the logarithm of a specified number in a specified base.
C# Syntax:
public static double Log(
   double a,
   double newBase
);
Parameters:

a

A number whose logarithm is to be found.

newBase

The base of the logarithm.

Return Value:


Sign of Returns
Positive The logarithm of , in base, ; that is, log .
Zero Double.PositiveInfinity
Negative Double.NaN
If a is equal to Double.PositiveInfinity and newBase is not equal to Double.PositiveInfinity, Double.NegativeInfinity, or Double.NaN, this method returns Double.PositiveInfinity. If newBase is equal to Double.PositiveInfinity and a is not equal to Double.PositiveInfinity, Double.NegativeInfinity, or Double.NaN, this method returns 0. If both a and newBase are equal to Double.PositiveInfinity, or a or newBase is equal to Double.NaN or Double.NegativeInfinity, this method returns Double.NaN.
Remarks
Parameters a and newBase are specified as base 10 numbers.

Return to top


Method: Log10(
   double d
)
Summary
Returns the base 10 logarithm of a specified number.
C# Syntax:
public static double Log10(
   double d
);
Parameters:

d

A number whose logarithm is to be found.

Return Value:


Sign of Returns
Positive The base 10 log of ; that is, log .
Zero Double.PositiveInfinity
Negative Double.NaN
If d is equal to Double.NaN, thsi method returns Double.NaN. If d is equal to Double.PositiveInfinity, this method returns Double.PositiveInfinity.
Remarks
Parameter d is specified as a base 10 number.

Return to top


Overloaded Method: Max(
   byte val1,
   byte val2
)
Summary
Returns the larger of two 8-bit unsigned integers.
C# Syntax:
public static byte Max(
   byte val1,
   byte val2
);
Parameters:

val1

The first of two 8-bit unsigned integers to compare.

val2

The second of two 8-bit unsigned integers to compare.

Return Value:
Parameter val1 or val2, whichever is larger.

Return to top


Overloaded Method: Max(
   decimal val1,
   decimal val2
)
Summary
Returns the larger of two decimal numbers.
C# Syntax:
public static decimal Max(
   decimal val1,
   decimal val2
);
Parameters:

val1

The first of two Decimal numbers to compare.

val2

The second of two Decimal numbers to compare.

Return Value:
Parameter val1 or val2, whichever is larger.

Return to top


Overloaded Method: Max(
   double val1,
   double val2
)
Summary
Returns the larger of two double-precision floating-point numbers.
C# Syntax:
public static double Max(
   double val1,
   double val2
);
Parameters:

val1

The first of two double-precision floating-point numbers to compare.

val2

The second of two double-precision floating-point numbers to compare.

Return Value:
Parameter val1 or val2, whichever is larger. If val1 or val2 exclusively is equal to Double.NaN, the other value is returned. If both val1 and val2 are equal to Double.NaN, Double.NaN is returned.

Return to top


Overloaded Method: Max(
   short val1,
   short val2
)
Summary
Returns the larger of two 16-bit signed integers.
C# Syntax:
public static short Max(
   short val1,
   short val2
);
Parameters:

val1

The first of two 16-bit signed integers to compare.

val2

The second of two 16-bit signed integers to compare.

Return Value:
Parameter val1 or val2, whichever is larger.

Return to top


Overloaded Method: Max(
   int val1,
   int val2
)
Summary
Returns the larger of two 32-bit signed integers.
C# Syntax:
public static int Max(
   int val1,
   int val2
);
Parameters:

val1

The first of two 32-bit signed integers to compare.

val2

The second of two 32-bit signed integers to compare.

Return Value:
Parameter val1 or val2, whichever is larger.

Return to top


Overloaded Method: Max(
   long val1,
   long val2
)
Summary
Returns the larger of two 64-bit signed integers.
C# Syntax:
public static long Max(
   long val1,
   long val2
);
Parameters:

val1

The first of two 64-bit signed integers to compare.

val2

The second of two 64-bit signed integers to compare.

Return Value:
Parameter val1 or val2, whichever is larger.

Return to top


Overloaded Method: Max(
   sbyte val1,
   sbyte val2
)
Summary
Returns the larger of two 8-bit signed integers.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static sbyte Max(
   sbyte val1,
   sbyte val2
);
Parameters:

val1

The first of two 8-bit unsigned integers to compare.

val2

The second of two 8-bit unsigned integers to compare.

Return Value:
Parameter val1 or val2, whichever is larger.

Return to top


Overloaded Method: Max(
   float val1,
   float val2
)
Summary
Returns the larger of two single-precision floating-point numbers.
C# Syntax:
public static float Max(
   float val1,
   float val2
);
Parameters:

val1

The first of two single-precision floating-point numbers to compare.

val2

The second of two single-precision floating-point numbers to compare.

Return Value:
Parameter val1 or val2, whichever is larger. If val1 or val2 exclusively is equal to Single.NaN, the other value is returned. If both val1 and val2 are equal to Single.NaN, Single.NaN is returned.

Return to top


Overloaded Method: Max(
   ushort val1,
   ushort val2
)
Summary
Returns the larger of two 16-bit unsigned integers.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ushort Max(
   ushort val1,
   ushort val2
);
Parameters:

val1

The first of two 16-bit unsigned integers to compare.

val2

The second of two 16-bit unsigned integers to compare.

Return Value:
Parameter val1 or val2, whichever is larger.

Return to top


Overloaded Method: Max(
   uint val1,
   uint val2
)
Summary
Returns the larger of two 32-bit unsigned integers.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static uint Max(
   uint val1,
   uint val2
);
Parameters:

val1

The first of two 32-bit unsigned integers to compare.

val2

The second of two 32-bit unsigned integers to compare.

Return Value:
Parameter val1 or val2, whichever is larger.

Return to top


Overloaded Method: Max(
   ulong val1,
   ulong val2
)
Summary
Returns the larger of two 64-bit unsigned integers.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ulong Max(
   ulong val1,
   ulong val2
);
Parameters:

val1

The first of two 64-bit unsigned integers to compare.

val2

The second of two 64-bit unsigned integers to compare.

Return Value:
Parameter val1 or val2, whichever is larger.

Return to top


Method: MemberwiseClone()
Inherited
See base class member description: System.Object.MemberwiseClone
C# Syntax:
protected object MemberwiseClone();

For more information on members inherited from System.Object click on the link above.

Return to top


Overloaded Method: Min(
   byte val1,
   byte val2
)
Summary
Returns the smaller of two 8-bit unsigned integers.
C# Syntax:
public static byte Min(
   byte val1,
   byte val2
);
Parameters:

val1

The first of two 8-bit unsigned integers to compare.

val2

The second of two 8-bit unsigned integers to compare.

Return Value:
Parameter val1 or val2, whichever is smaller.

Return to top


Overloaded Method: Min(
   decimal val1,
   decimal val2
)
Summary
Returns the smaller of two decimal numbers.
C# Syntax:
public static decimal Min(
   decimal val1,
   decimal val2
);
Parameters:

val1

The first of two Decimal numbers to compare.

val2

The second of two Decimal numbers to compare.

Return Value:
Parameter val1 or val2, whichever is smaller.

Return to top


Overloaded Method: Min(
   double val1,
   double val2
)
Summary
Returns the smaller of two double-precision floating-point numbers.
C# Syntax:
public static double Min(
   double val1,
   double val2
);
Parameters:

val1

The first of two double-precision floating-point numbers to compare.

val2

The second of two double-precision floating-point numbers to compare.

Return Value:
Parameter val1 or val2, whichever is smaller. If val1 or val2 exclusively is equal to Double.NaN, the other value is returned. If both val1 and val2 are equal to Double.NaN, Double.NaN is returned.

Return to top


Overloaded Method: Min(
   short val1,
   short val2
)
Summary
Returns the smaller of two 16-bit signed integers.
C# Syntax:
public static short Min(
   short val1,
   short val2
);
Parameters:

val1

The first of two 16-bit signed integers to compare.

val2

The second of two 16-bit signed integers to compare.

Return Value:
Parameter val1 or val2, whichever is smaller.

Return to top


Overloaded Method: Min(
   int val1,
   int val2
)
Summary
Returns the smaller of two 32-bit signed integers.
C# Syntax:
public static int Min(
   int val1,
   int val2
);
Parameters:

val1

The first of two 32-bit signed integers to compare.

val2

The second of two 32-bit signed integers to compare.

Return Value:
Parameter val1 or val2, whichever is smaller.

Return to top


Overloaded Method: Min(
   long val1,
   long val2
)
Summary
Returns the smaller of two 64-bit signed integers.
C# Syntax:
public static long Min(
   long val1,
   long val2
);
Parameters:

val1

The first of two 64-bit signed integers to compare.

val2

The second of two 64-bit signed integers to compare.

Return Value:
Parameter val1 or val2, whichever is smaller.

Return to top


Overloaded Method: Min(
   sbyte val1,
   sbyte val2
)
Summary
Returns the smaller of two 8-bit signed integers.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static sbyte Min(
   sbyte val1,
   sbyte val2
);
Parameters:

val1

The first of two 8-bit signed integers to compare.

val2

The second of two 8-bit signed integers to compare.

Return Value:
Parameter val1 or val2, whichever is smaller.

Return to top


Overloaded Method: Min(
   float val1,
   float val2
)
Summary
Returns the smaller of two single-precision floating-point numbers.
C# Syntax:
public static float Min(
   float val1,
   float val2
);
Parameters:

val1

The first of two single-precision floating-point numbers to compare.

val2

The second of two single-precision floating-point numbers to compare.

Return Value:
Parameter val1 or val2, whichever is smaller. If val1 or val2 exclusively is equal to Single.NaN, the other value is returned. If both val1 and val2 are equal to Single.NaN, Single.NaN is returned.

Return to top


Overloaded Method: Min(
   ushort val1,
   ushort val2
)
Summary
Returns the smaller of two 16-bit unsigned integers.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ushort Min(
   ushort val1,
   ushort val2
);
Parameters:

val1

The first of two 16-bit unsigned integers to compare.

val2

The second of two 16-bit unsigned integers to compare.

Return Value:
Parameter val1 or val2, whichever is smaller.

Return to top


Overloaded Method: Min(
   uint val1,
   uint val2
)
Summary
Returns the smaller of two 32-bit unsigned integers.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static uint Min(
   uint val1,
   uint val2
);
Parameters:

val1

The first of two 32-bit unsigned integers to compare.

val2

The second of two 32-bit unsigned integers to compare.

Return Value:
Parameter val1 or val2, whichever is smaller.

Return to top


Overloaded Method: Min(
   ulong val1,
   ulong val2
)
Summary
Returns the smaller of two 64-bit unsigned integers.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static ulong Min(
   ulong val1,
   ulong val2
);
Parameters:

val1

The first of two 64-bit unsigned integers to compare.

val2

The second of two 64-bit unsigned integers to compare.

Return Value:
Parameter val1 or val2, whichever is smaller.

Return to top


Method: Pow(
   double x,
   double y
)
Summary
Returns a specified number raised to the specified power.
C# Syntax:
public static double Pow(
   double x,
   double y
);
Parameters:

x

A number to be raised to a power.

y

A number that specifies a power.

Return Value:
The number x raised to the power y. The following table specifies the results if x or y is equal to Double.NaN, Double.NegativeInfinity, or Double.PositiveInfinity.

Parameter Values Returns
or is equal to Double.NaN Double.NaN.
is equal to Double.NegativeInfinity Double.NegativeInfinity if is an odd integer; otherwise, Double.PositiveInfinity .
is equal to Double.NegativeInfinity 0.
is equal to Double.PositiveInfinity 0 if is equal to Double.NegativeInfinity ; otherwise, Double.PositiveInfinity .
is equal to Double.PositiveInfinity Double.PositiveInfinity .

Return to top


Overloaded Method: Round(
   decimal d
)
Summary
Returns the whole number nearest the specified value.
C# Syntax:
public static decimal Round(
   decimal d
);
Parameters:

d

A Decimal number to be rounded.

Return Value:
The whole number nearest parameter d. If d is halfway between two whole numbers, one of which by definition is even and the other odd, then the even number is returned.
Remarks
The behavior of this method follows IEEE Standard 754, section 4. This kind of rounding is sometimes called rounding to nearest, or banker's rounding.
Example
The following code example demonstrates rounding to nearest.
        Math.Round(4.4); //Returns 4.0.
        Math.Round(4.5); //Returns 4.0.
        Math.Round(4.6); //Returns 5.0.

    
See also:
Math.Ceiling | Math.Floor

Return to top


Overloaded Method: Round(
   double a
)
Summary
Returns the whole number nearest the specified value.
C# Syntax:
public static double Round(
   double a
);
Parameters:

a

A double-precision floating-point number to be rounded.

Return Value:
The whole number nearest a. If a is halfway between two whole numbers, one of which by definition is even and the other odd, then the even number is returned.
Remarks
The behavior of this method follows IEEE Standard 754, section 4. This kind of rounding is sometimes called rounding to nearest, or banker's rounding.
Example
The following code example demonstrates rounding to nearest.
        Math.Round(4.4); //Returns 4.0.
        Math.Round(4.5); //Returns 4.0.
        Math.Round(4.6); //Returns 5.0.

    
See also:
Math.Ceiling | Math.Floor

Return to top


Overloaded Method: Round(
   decimal d,
   int decimals
)
Summary
Returns the number with the specified precision nearest the specified value.
C# Syntax:
public static decimal Round(
   decimal d,
   int decimals
);
Parameters:

d

A Decimal number to be rounded.

decimals

The number of significant fractional digits (precision) in the return value.

Return Value:
The number nearest d with precision equal to decimals. If d is halfway between two numbers, one of which is even and the other odd, then the even number is returned. If the precision of d is less than decimals, then d is returned unchanged.
Remarks
The decimals parameter specifies the number of significant fractional digits in the return value and ranges from 0 to 28. If decimals is zero, then a whole number is returned.

The behavior of this method follows IEEE Standard 754, section 4. This kind of rounding is sometimes called rounding to nearest, or banker's rounding. If decimals is zero, this kind of rounding is sometimes called rounding toward zero.

Example
The following code example demonstrates rounding to nearest.
        Math.Round(3.44, 1); //Returns 3.4.
        Math.Round(3.45, 1); //Returns 3.4.
        Math.Round(3.46, 1); //Returns 3.5.

    
See also:
Math.Ceiling | Math.Floor

Return to top


Overloaded Method: Round(
   double value,
   int digits
)
Summary
Returns the number with the specified precision nearest the specified value.
C# Syntax:
public static double Round(
   double value,
   int digits
);
Parameters:

value

A double-precision floating-point number to be rounded.

digits

The number of significant fractional digits (precision) in the return value.

Return Value:
The number nearest value with precision equal to digits. If value is halfway between two numbers, one of which is even and the other odd, then the even number is returned. If the precision of value is less than digits, then value is returned unchanged.
Remarks
The digits parameter specifies the number of significant fractional digits in the return value and ranges from 0 to 15. If digits is zero, then a whole number is returned.

The behavior of this method follows IEEE Standard 754, section 4. This kind of rounding is sometimes called rounding to nearest, or banker's rounding. If digits is zero, this kind of rounding is sometimes called rounding toward zero.

Example
The following code example demonstrates rounding to nearest.
        Math.Round(3.44, 1); //Returns 3.4.
        Math.Round(3.45, 1); //Returns 3.4.
        Math.Round(3.46, 1); //Returns 3.5.

    
See also:
Math.Ceiling | Math.Floor

Return to top


Overloaded Method: Sign(
   decimal value
)
Summary
Returns a value indicating the sign of a decimal number.
C# Syntax:
public static int Sign(
   decimal value
);
Parameters:

value

A signed Decimal number.

Return Value:
A number indicating the sign of value.

Number Description
-1 is less than zero.
0 is equal to zero.
1 is greater than zero.

Return to top


Overloaded Method: Sign(
   double value
)
Summary
Returns a value indicating the sign of a double-precision floating-point number.
C# Syntax:
public static int Sign(
   double value
);
Parameters:

value

A signed number.

Return Value:
A number indicating the sign of value.

Number Description
-1 is less than zero.
0 is equal to zero.
1 is greater than zero.
Exceptions
Exception Type Condition
ArithmeticException value is equal to Double.NaN.

Return to top


Overloaded Method: Sign(
   short value
)
Summary
Returns a value indicating the sign of a 16-bit signed integer.
C# Syntax:
public static int Sign(
   short value
);
Parameters:

value

A signed number.

Return Value:
A number indicating the sign of value.

Number Description
-1 is less than zero.
0 is equal to zero.
1 is greater than zero.

Return to top


Overloaded Method: Sign(
   int value
)
Summary
Returns a value indicating the sign of a 32-bit signed integer.
C# Syntax:
public static int Sign(
   int value
);
Parameters:

value

A signed number.

Return Value:
A number indicating the sign of value.

Number Description
-1 is less than zero.
0 is equal to zero.
1 is greater than zero.

Return to top


Overloaded Method: Sign(
   long value
)
Summary
Returns a value indicating the sign of a 64-bit signed integer.
C# Syntax:
public static int Sign(
   long value
);
Parameters:

value

A signed number.

Return Value:
A number indicating the sign of value.

Number Description
-1 is less than zero.
0 is equal to zero.
1 is greater than zero.

Return to top


Overloaded Method: Sign(
   sbyte value
)
Summary
Returns a value indicating the sign of an 8-bit signed integer.
This member is not CLS Compliant

C# Syntax:
[CLSCompliant(false)]
public static int Sign(
   sbyte value
);
Parameters:

value

A signed number.

Return Value:
A number indicating the sign of value.

Number Description
-1 is less than zero.
0 is equal to zero.
1 is greater than zero.

Return to top


Overloaded Method: Sign(
   float value
)
Summary
Returns a value indicating the sign of a single-precision floating-point number.
C# Syntax:
public static int Sign(
   float value
);
Parameters:

value

A signed number.

Return Value:
A number indicating the sign of value.

Number Description
-1 is less than zero.
0 is equal to zero.
1 is greater than zero.
Exceptions
Exception Type Condition
ArithmeticException value is equal to Single.NaN.

Return to top


Method: Sin(
   double a
)
Summary
Returns the sine of the specified angle.
C# Syntax:
public static double Sin(
   double a
);
Parameters:

a

An angle, measured in radians.

Return Value:
The sine of a. If a is equal to Double.NaN, Double.NegativeInfinity, or Double.PositiveInfinity, this method returns Double.NaN.
Remarks
The angle, a, must be in radians. Multiply by (pi)/180 to convert degrees to radians.

Return to top


Method: Sinh(
   double value
)
Summary
Returns the hyperbolic sine of the specified angle.
C# Syntax:
public static double Sinh(
   double value
);
Parameters:

value

An angle, measured in radians.

Return Value:
The hyperbolic sine of value. If value is equal to Double.NegativeInfinity, Double.PositiveInfinity, or Double.NaN, this method returns a Double equal to value.
Remarks
The angle, value, must be in radians. Multiply by (pi)/180 to convert degrees to radians.

Return to top


Method: Sqrt(
   double d
)
Summary
Returns the square root of a specified number.
C# Syntax:
public static double Sqrt(
   double d
);
Parameters:

d

A number.

Return Value:


Value of Returns
Zero, or positive The positive square root of .
Negative Double.NaN
If d is equal to Double.NaN or Double.PositiveInfinity, that value is returned.

Return to top


Method: Tan(
   double a
)
Summary
Returns the tangent of the specified angle.
C# Syntax:
public static double Tan(
   double a
);
Parameters:

a

An angle, measured in radians.

Return Value:
The tangent of a. If a is equal to Double.NaN, Double.NegativeInfinity, or Double.PositiveInfinity, this method returns Double.NaN.
Remarks
The angle, a, must be in radians. Multiply by (pi)/180 to convert degrees to radians.

Return to top


Method: Tanh(
   double value
)
Summary
Returns the hyperbolic tangent of the specified angle.
C# Syntax:
public static double Tanh(
   double value
);
Parameters:

value

An angle, measured in radians.

Return Value:
The hyperbolic tangent of value. If value is equal to Double.NegativeInfinity, this method returns -1. If value is equal to Double.PositiveInfinity, this method returns 1. If value is equal to Double.NaN, this method returns Double.NaN.
Remarks
The angle, value, must be in radians. Multiply by (pi)/180 to convert degrees to radians.

Return to top


Method: ToString()
Inherited
See base class member description: System.Object.ToString
C# Syntax:
public virtual string ToString();

For more information on members inherited from System.Object click on the link above.

Return to top


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.