Functions

The following functions are available globally.

  • Computes the absolute value of a number.

    Declaration

    func abs(_ x: Double) -> Double

    Parameters

    x

    A number value.

    Return Value

    The absolute value of x.

  • Computes the arc tangent of two numbers.

    The atan2() function is used to convert from rectangular (x,y) to polar (r,theta) coordinates where theta = atan2(y, x).

    Declaration

    func atan2(_ y: Double, _ x: Double) -> Double

    Parameters

    y

    A number value.

    x

    A number value.

    Return Value

    The arc tangent of y/x, taking into account the signs of both arguments to determine the quadrant.

  • Computes the ceiling (rounding up) of a number.

    Declaration

    func ceil(_ x: Double) -> Double

    Parameters

    x

    A number value.

    Return Value

    The smallest integer greater than or equal to x.

  • Computes the cosine of a number.

    Declaration

    func cos(_ x: Double) -> Double

    Parameters

    x

    A number value.

    Return Value

    The cosine of x.

  • Computes the base-e exponential of a number.

    Declaration

    func exp(_ x: Double) -> Double

    Parameters

    x

    A number value.

    Return Value

    Euler’s number e to raised to the power of x.

  • Computes the floor (rounding down) of a number.

    Declaration

    func floor(_ x: Double) -> Double

    Parameters

    x

    A number value.

    Return Value

    The largest integer less than or equal to x.

  • Computes the natural logarithm of a number.

    Declaration

    func log(_ x: Double) -> Double

    Parameters

    x

    A number value.

    Return Value

    The natural logarithm of x.

  • Computes the power function.

    Declaration

    func pow(_ x: Double, _ y: Double) -> Double

    Parameters

    x

    A number value used as the base.

    y

    A number value used as the exponent.

    Return Value

    x raised to the power of y.

  • Rounds a number to the closest integer.

    Declaration

    func round(_ x: Double) -> Double

    Parameters

    x

    A number value.

    Return Value

    The integer closest to x, half-way cases round away from zero.

  • Computes the sine of a number.

    Declaration

    func sin(_ x: Double) -> Double

    Parameters

    x

    A number value.

    Return Value

    The sine of x.

  • Computes the square root of a number.

    Declaration

    func sqrt(_ x: Double) -> Double

    Parameters

    x

    A number value.

    Return Value

    The square root of x.

  • Computes the tangent of a number.

    Declaration

    func tan(_ x: Double) -> Double

    Parameters

    x

    A number value.

    Return Value

    The tangent of x.