Show / Hide Table of Contents

    Class Math

    Provides constants and static methods for trigonometric, logarithmic, and other common mathematical functions.

    Inheritance
    Object
    Math
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: System
    Assembly: System.Math.dll
    Syntax
    public static class Math

    Fields

    | Improve this Doc View Source

    E

    Represents the natural logarithmic base, specified by the constant, e.

    Declaration
    public const double E = 2.7182818284590451
    Field Value
    Type Description
    Double
    Remarks

    The value of this field is 2.7182818284590452354.

    | Improve this Doc View Source

    PI

    Represents the ratio of the circumference of a circle to its diameter, specified by the constant, π.

    Declaration
    public const double PI = 3.1415926535897931
    Field Value
    Type Description
    Double
    Remarks

    The value of this field is 3.14159265358979323846.

    Methods

    Abs(Double)

    Returns the absolute value of a double-precision floating-point number.

    Declaration
    public static extern double Abs(double value)
    Parameters
    Type Name Description
    Double value

    A number that is greater than or equal to MinValue, but less than or equal to MaxValue.

    Returns
    Type Description
    Double

    A double-precision floating-point number, x, such that 0 ≤ x ≤ MaxValue.

    | Improve this Doc View Source

    Abs(Int32)

    Returns the absolute value of a 32-bit signed integer.

    Declaration
    public static int Abs(int value)
    Parameters
    Type Name Description
    Int32 value

    A number that is greater than MinValue, but less than or equal to MaxValue.

    Returns
    Type Description
    Int32

    A 32-bit signed integer, x, such that 0 ≤ x ≤ MaxValue.

    Abs(Single)

    Returns the absolute value of a single-precision floating-point number.

    Declaration
    public static extern float Abs(float value)
    Parameters
    Type Name Description
    Single value

    A number that is greater than or equal to MinValue, but less than or equal to MaxValue.

    Returns
    Type Description
    Single

    A single-precision floating-point number, x, such that 0 ≤ x ≤ MaxValue.

    Acos(Double)

    Returns the angle whose cosine is the specified number.

    Declaration
    public static extern double Acos(double d)
    Parameters
    Type Name Description
    Double d

    A number representing a cosine, where d must be greater than or equal to -1, but less than or equal to 1.

    Returns
    Type Description
    Double

    An angle, θ, measured in radians, such that 0 ≤ θ ≤ π -or- NaN if d < -1 or d > 1 or d equals NaN.

    Asin(Double)

    Returns the angle whose sine is the specified number.

    Declaration
    public static extern double Asin(double d)
    Parameters
    Type Name Description
    Double d

    A number representing a sine, where d must be greater than or equal to -1, but less than or equal to 1.

    Returns
    Type Description
    Double

    An angle, θ, measured in radians, such that -π/2 ≤ θ ≤ π/2 -or- NaN if d < -1 or d> 1 or d equals NaN.

    Atan(Double)

    Returns the angle whose tangent is the specified number.

    Declaration
    public static extern double Atan(double d)
    Parameters
    Type Name Description
    Double d

    A number representing a tangent.

    Returns
    Type Description
    Double

    An angle, θ, measured in radians, such that -π/2 ≤ θ ≤ π/2. -or- NaN if d equals NaN, -π/2 rounded to double precision(-1.5707963267949) if d equals NegativeInfinity, or π/2 rounded to double precision(1.5707963267949) if d equals PositiveInfinity.

    Atan2(Double, Double)

    Returns the angle whose tangent is the quotient of two specified numbers.

    Declaration
    public static extern double Atan2(double y, double x)
    Parameters
    Type Name Description
    Double y

    The y coordinate of a point.

    Double x

    The x coordinate of a point.

    Returns
    Type Description
    Double

    An angle, θ, measured in radians, such that -π ≤ θ ≤ π, and tan(θ) = y / x, where (x, y) is a point in the Cartesian plane.

    Cbrt(Double)

    Returns the cube root of a specified number.

    Declaration
    public static extern double Cbrt(double d)
    Parameters
    Type Name Description
    Double d

    The number whose cube root is to be found.

    Returns
    Type Description
    Double

    The cube root of d. -or- NaN if d equals NaN.

    Ceiling(Double)

    Returns the smallest integral value that is greater than or equal to the specified double-precision floating-point number.

    Declaration
    public static extern double Ceiling(double d)
    Parameters
    Type Name Description
    Double d

    A double-precision floating-point number.

    Returns
    Type Description
    Double

    The smallest integral value that is greater than or equal to d. If d is equal to NaN, NegativeInfinity, or PositiveInfinity, that value is returned. Note that this method returns a Double instead of an integral type.

    | Improve this Doc View Source

    Clamp(Double, Double, Double)

    Returns value clamped to the inclusive range of min and max.

    Declaration
    public static double Clamp(double value, double min, double max)
    Parameters
    Type Name Description
    Double value

    The value to be clamped.

    Double min

    The lower bound of the result.

    Double max

    The upper bound of the result.

    Returns
    Type Description
    Double

    value if min ≤ value ≤ max. -or- min if value<min. -or- max if max<value.

    Exceptions
    Type Condition
    ArgumentException

    If max < min.

    | Improve this Doc View Source

    Clamp(Int64, Int64, Int64)

    Returns value clamped to the inclusive range of min and max.

    Declaration
    public static long Clamp(long value, long min, long max)
    Parameters
    Type Name Description
    Int64 value

    The value to be clamped.

    Int64 min

    The lower bound of the result.

    Int64 max

    The upper bound of the result.

    Returns
    Type Description
    Int64

    value if min ≤ value ≤ max. -or- min if value<min. -or- max if max<value.

    Exceptions
    Type Condition
    ArgumentException

    If max < min.

    | Improve this Doc View Source

    Clamp(Single, Single, Single)

    Returns value clamped to the inclusive range of min and max.

    Declaration
    public static float Clamp(float value, float min, float max)
    Parameters
    Type Name Description
    Single value

    The value to be clamped.

    Single min

    The lower bound of the result.

    Single max

    The upper bound of the result.

    Returns
    Type Description
    Single

    value if min ≤ value ≤ max. -or- min if value<min. -or- max if max<value.

    Exceptions
    Type Condition
    ArgumentException

    If max < min.

    | Improve this Doc View Source

    Clamp(UInt64, UInt64, UInt64)

    Returns value clamped to the inclusive range of min and max.

    Declaration
    public static ulong Clamp(ulong value, ulong min, ulong max)
    Parameters
    Type Name Description
    UInt64 value

    The value to be clamped.

    UInt64 min

    The lower bound of the result.

    UInt64 max

    The upper bound of the result.

    Returns
    Type Description
    UInt64

    value if min ≤ value ≤ max. -or- min if value<min. -or- max if max<value.

    Exceptions
    Type Condition
    ArgumentException

    If max < min.

    Cos(Double)

    Returns the cosine of the specified angle.

    Declaration
    public static extern double Cos(double a)
    Parameters
    Type Name Description
    Double a

    An angle, measured in radians.

    Returns
    Type Description
    Double

    The cosine of a. If a is equal to NaN, NegativeInfinity, or PositiveInfinity, this method returns NaN.

    Cosh(Double)

    Returns the hyperbolic cosine of the specified angle.

    Declaration
    public static extern double Cosh(double value)
    Parameters
    Type Name Description
    Double value

    An angle, measured in radians.

    Returns
    Type Description
    Double

    The hyperbolic cosine of value. If value is equal to NegativeInfinity or PositiveInfinity, PositiveInfinity is returned. If value is equal to NaN, NaN is returned.

    Exp(Double)

    Returns e raised to the specified power.

    Declaration
    public static extern double Exp(double d)
    Parameters
    Type Name Description
    Double d

    A number specifying a power.

    Returns
    Type Description
    Double

    The number e raised to the power d. If d equals NaN or PositiveInfinity, that value is returned. If d equals NegativeInfinity, 0 is returned.

    Floor(Double)

    Returns the largest integer less than or equal to the specified double-precision floating-point number.

    Declaration
    public static extern double Floor(double d)
    Parameters
    Type Name Description
    Double d

    A double-precision floating-point number.

    Returns
    Type Description
    Double

    The largest integer less than or equal to d. If d is equal to NaN, NegativeInfinity, or PositiveInfinity, that value is returned.

    IEEERemainder(Double, Double)

    Returns the remainder resulting from the division of a specified number by another specified number.

    Declaration
    public static extern double IEEERemainder(double x, double y)
    Parameters
    Type Name Description
    Double x

    A dividend.

    Double y

    A divisor.

    Returns
    Type Description
    Double

    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, NaN is returned.

    Log(Double)

    Returns the natural (base e) logarithm of a specified number.

    Declaration
    public static extern double Log(double d)
    Parameters
    Type Name Description
    Double d

    The number whose logarithm is to be found.

    Returns
    Type Description
    Double

    The natural logarithm of d; that is, ln d, or log e d

    Log10(Double)

    Returns the base 10 logarithm of a specified number.

    Declaration
    public static extern double Log10(double d)
    Parameters
    Type Name Description
    Double d

    A number whose logarithm is to be found.

    Returns
    Type Description
    Double

    The base 10 log of d; that is, log 10 d.

    Max(Double, Double)

    Returns the larger of two double-precision floating-point numbers.

    Declaration
    public static extern double Max(double val1, double val2)
    Parameters
    Type Name Description
    Double val1

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

    Double val2

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

    Returns
    Type Description
    Double

    Parameter val1 or val2, whichever is larger. If val1, val2, or both val1 and val2 are equal to NaN, NaN is returned.

    | Improve this Doc View Source

    Max(Int32, Int32)

    Returns the larger of two 32-bit signed integers.

    Declaration
    public static int Max(int val1, int val2)
    Parameters
    Type Name Description
    Int32 val1

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

    Int32 val2

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

    Returns
    Type Description
    Int32

    Parameter val1 or val2, whichever is larger.

    | Improve this Doc View Source

    Max(Single, Single)

    Returns the larger of two single-precision floating-point numbers.

    Declaration
    public static float Max(float val1, float val2)
    Parameters
    Type Name Description
    Single val1

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

    Single val2

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

    Returns
    Type Description
    Single

    Parameter val1 or val2, whichever is larger. If val1, or val2, or both val1 and val2 are equal to NaN, NaN is returned.

    Min(Double, Double)

    Returns the smaller of two double-precision floating-point numbers.

    Declaration
    public static extern double Min(double val1, double val2)
    Parameters
    Type Name Description
    Double val1

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

    Double val2

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

    Returns
    Type Description
    Double

    Parameter val1 or val2, whichever is smaller. If val1, val2, or both val1 and val2 are equal to NaN, NaN is returned.

    | Improve this Doc View Source

    Min(Int32, Int32)

    Returns the smaller of two 32-bit signed integers.

    Declaration
    public static int Min(int val1, int val2)
    Parameters
    Type Name Description
    Int32 val1

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

    Int32 val2

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

    Returns
    Type Description
    Int32

    Parameter val1 or val2, whichever is smaller.

    | Improve this Doc View Source

    Min(Single, Single)

    Returns the smaller of two single-precision floating-point numbers.

    Declaration
    public static float Min(float val1, float val2)
    Parameters
    Type Name Description
    Single val1

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

    Single val2

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

    Returns
    Type Description
    Single

    Parameter val1 or val2, whichever is smaller. If val1, val2, or both val1 and val2 are equal to NaN, NaN is returned.

    Pow(Double, Double)

    Returns a specified number raised to the specified power.

    Declaration
    public static extern double Pow(double x, double y)
    Parameters
    Type Name Description
    Double x

    A double-precision floating-point number to be raised to a power.

    Double y

    A double-precision floating-point number that specifies a power.

    Returns
    Type Description
    Double

    The number x raised to the power y.

    Round(Double)

    Rounds a double-precision floating-point value to the nearest integral value.

    Declaration
    public static extern double Round(double a)
    Parameters
    Type Name Description
    Double a

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

    Returns
    Type Description
    Double

    The integer nearest a. If the fractional component of a is halfway between two integers, one of which is even and the other odd, then the even number is returned. Note that this method returns a Double instead of an integral type.

    Sign(Double)

    Returns a value indicating the sign of a double-precision floating-point number.

    Declaration
    public static extern int Sign(double value)
    Parameters
    Type Name Description
    Double value

    A signed number.

    Returns
    Type Description
    Int32

    A number that indicates the sign of value.

    | Improve this Doc View Source

    Sign(Single)

    Returns a value indicating the sign of a single-precision floating-point number.

    Declaration
    public static int Sign(float value)
    Parameters
    Type Name Description
    Single value

    A signed number.

    Returns
    Type Description
    Int32

    A number that indicates the sign of value.

    Sin(Double)

    Returns the sine of the specified angle.

    Declaration
    public static extern double Sin(double a)
    Parameters
    Type Name Description
    Double a

    An angle, measured in radians.

    Returns
    Type Description
    Double

    The sine of a. If a is equal to NaN, NegativeInfinity, or PositiveInfinity, this method returns NaN.

    Sinh(Double)

    Returns the hyperbolic sine of the specified angle.

    Declaration
    public static extern double Sinh(double value)
    Parameters
    Type Name Description
    Double value

    An angle, measured in radians.

    Returns
    Type Description
    Double

    The hyperbolic sine of value. If value is equal to NegativeInfinity, PositiveInfinity, or NaN, this method returns a Double equal to value.

    Sqrt(Double)

    Returns the square root of a specified number.

    Declaration
    public static extern double Sqrt(double d)
    Parameters
    Type Name Description
    Double d

    The number whose square root is to be found.

    Returns
    Type Description
    Double

    The positive square root of d.

    Tan(Double)

    Returns the tangent of the specified angle.

    Declaration
    public static extern double Tan(double a)
    Parameters
    Type Name Description
    Double a

    An angle, measured in radians.

    Returns
    Type Description
    Double

    The tangent of a. If a is equal to NaN, NegativeInfinity, or PositiveInfinity, this method returns NaN.

    Tanh(Double)

    Returns the hyperbolic tangent of the specified angle.

    Declaration
    public static extern double Tanh(double value)
    Parameters
    Type Name Description
    Double value

    An angle, measured in radians.

    Returns
    Type Description
    Double

    The hyperbolic tangent of value. If value is equal to NegativeInfinity, this method returns -1. If value is equal to PositiveInfinity, this method returns 1. If value is equal to NaN, this method returns NaN.

    Truncate(Double)

    Calculates the integral part of a specified double-precision floating-point number.

    Declaration
    public static extern double Truncate(double d)
    Parameters
    Type Name Description
    Double d

    A number to truncate.

    Returns
    Type Description
    Double

    The integral part of d; that is, the number that remains after any fractional digits have been discarded.

    • Improve this Doc
    • View Source
    Back to top Copyright © 2018 nanoFramework Contributors
    Generated by DocFX