Functions

func abs(Float16)

public func abs(x: Float16): Float16

Description: Obtains the absolute value of a half-precision floating-point number.

Parameters:

  • x: Float16: half-precision floating-point number input

Returns:

  • Float16: The absolute value of the input parameter is returned.

Examples:

import std.math.abs

main() {
    let n: Float16 = -23.0
    let abs = abs(n)
    println(abs)
}

Results:

23.000000

func abs(Float32)

public func abs(x: Float32): Float32

Description: Obtains the absolute value of a single-precision floating-point number.

Parameters:

  • x: Float32: single-precision floating-point number input

Returns:

  • Float32: The absolute value of the input parameter is returned.

Examples:

import std.math.abs

main() {
    let n: Float32 = -23.0
    let abs = abs(n)
    println(abs)
}

Results:

23.000000

func abs(Float64)

public func abs(x: Float64): Float64

Description: Obtains the absolute value of a double-precision floating-point number.

Parameters:

  • x: Float64: double-precision floating-point number input

Returns:

  • Float64: The absolute value of the input parameter is returned.

Examples:

import std.math.abs

main() {
    let n: Float64 = -23.0
    let abs = abs(n)
    println(abs)
}

Results:

23.000000

func abs(Int16)

public func abs(x: Int16): Int16

Description: Obtains the absolute value of a 16-bit signed integer.

Parameters:

  • x: Int16: 16-bit signed integer input

Returns:

  • Int16: The absolute value of the input parameter is returned.

Throws:

  • OverflowException: When the input parameter is the minimum value of the signed integer, this exception is thrown.

Examples:

import std.math.abs

main() {
    let n: Int16 = -23
    let abs = abs(n)
    println(abs)
}

Results:

23

Examples of Throws:

import std.math.abs

main(): Unit {
    try {
        let n = Int16(-2 ** 15)
        let abs: Int16 = abs(n)
        println(abs)
    } catch (e: OverflowException) {
        println("Throws: The input parameter is the minimum signed integer.")
    }
}

Results:

Throws: The input parameter is the minimum signed integer.

func abs(Int32)

public func abs(x: Int32): Int32

Description: Obtains the absolute value of a 32-bit signed integer.

Parameters:

  • x: Int32: 32-bit signed integer input

Returns:

  • Int32: The absolute value of the input parameter is returned.

Throws:

  • OverflowException: When the input parameter is the minimum value of the signed integer, this exception is thrown.

Examples:

import std.math.abs

main() {
    let n: Int32 = -23
    let abs = abs(n)
    println(abs)
}

Results:

23

func abs(Int64)

public func abs(x: Int64): Int64

Description: Obtains the absolute value of a 64-bit signed integer.

Parameters:

  • x: Int64: 64-bit signed integer input

Returns:

  • Int64: The absolute value of the input parameter is returned.

Throws:

  • OverflowException: When the input parameter is the minimum value of the signed integer, this exception is thrown.

Examples:

import std.math.abs

main() {
    let n: Int64 = -23
    let abs = abs(n)
    println(abs)
}

Results:

23

func abs(Int8)

public func abs(x: Int8): Int8

Description: Obtains the absolute value of an 8-bit signed integer.

Parameters:

  • x: Int8: 8-bit signed integer input

Returns:

  • Int8: The absolute value of the input parameter is returned.

Throws:

  • OverflowException: When the input parameter is the minimum value of the signed integer, this exception is thrown.

Examples:

import std.math.abs

main() {
    let n: Int8 = -23
    let abs = abs(n)
    println(abs)
}

Results:

23

func acos(Float16)

public func acos(x: Float16): Float16

Description: Obtains the arc cosine function value of a half-precision floating-point number through calculation.

Parameters:

  • x: Float16: half-precision floating-point number input (–1.0 ≤ x ≤ 1.0)

Returns:

  • Float16: The arc cosine function value of the input parameter, in radians, is returned.

Throws:

  • IllegalArgumentException: When the value of parameter x is greater than 1.0 or less than –1.0, this exception is thrown.

Examples:

import std.math.acos

main() {
    let n: Float16 = 1.0
    let acos = acos(n)
    println(acos)
}

Results:

0.000000

Examples of Throws:

import std.math.acos

main(): Unit {
    let n = -1.5
    let acos = acos(n)
    println(acos)
}

func acos(Float32)

public func acos(x: Float32): Float32

Description: Obtains the arc cosine function value of a single-precision floating-point number through calculation.

Parameters:

  • x: Float32: single-precision floating-point number input (–1.0 ≤ x ≤ 1.0)

Returns:

  • Float32: The arc cosine function value of the input parameter, in radians, is returned.

Throws:

  • IllegalArgumentException: When the value of parameter x is greater than 1.0 or less than –1.0, this exception is thrown.

Examples:

import std.math.acos

main() {
    let n: Float32 = 1.0
    let acos = acos(n)
    println(acos)
}

Results:

0.000000

func acos(Float64)

public func acos(x: Float64): Float64

Description: Obtains the arc cosine function value of a double-precision floating-point number through calculation.

Parameters:

  • x: Float64: double-precision floating-point number input (–1.0 ≤ x ≤ 1.0)

Returns:

  • Float64: The arc cosine function value of the input parameter, in radians, is returned.

Throws:

  • IllegalArgumentException: When the value of parameter x is greater than 1.0 or less than –1.0, this exception is thrown.

Examples:

import std.math.acos

main() {
    let n: Float64 = 1.0
    let acos = acos(n)
    println(acos)
}

Results:

0.000000

func acosh(Float16)

public func acosh(x: Float16): Float16

Description: Obtains the inverse hyperbolic cosine function value of a half-precision floating-point number through calculation.

Parameters:

  • x: Float16: half-precision floating-point number input

Returns:

  • Float16: The inverse hyperbolic cosine function value of the input parameter is returned. (x ≥ 1.0)

Throws:

Examples:

import std.math.acosh

main() {
    let n: Float16 = 1.0
    let acosh = acosh(n)
    println(acosh)
}

Results:

0.000000

Examples of Throws:

import std.math.acosh

main(): Unit {
    let n = 0.4
    let acosh = acosh(n)
    println(acosh)
}

func acosh(Float32)

public func acosh(x: Float32): Float32

Description: Obtains the inverse hyperbolic cosine function value of a single-precision floating-point number through calculation.

Parameters:

  • x: Float32: single-precision floating-point number input; (x ≥ 1.0)

Returns:

  • Float32: The inverse hyperbolic cosine function value of the input parameter is returned.

Throws:

Examples:

import std.math.acosh

main() {
    let n: Float32 = 1.0
    let acosh = acosh(n)
    println(acosh)
}

Results:

0.000000

func acosh(Float64)

public func acosh(x: Float64): Float64

Description: Obtains the inverse hyperbolic cosine function value of a double-precision floating-point number through calculation.

Parameters:

  • x: Float64: double-precision floating-point number input (x ≥ 1.0)

Returns:

  • Float64: The inverse hyperbolic cosine function value of the input parameter is returned.

Throws:

Examples:

import std.math.acosh

main() {
    let n: Float64 = 1.0
    let acosh = acosh(n)
    println(acosh)
}

Results:

0.000000

func asin(Float16)

public func asin(x: Float16): Float16

Description: Obtains the arc sine function value of a half-precision floating-point number through calculation.

Parameters:

  • x: Float16: half-precision floating-point number input (–1.0 ≤ x ≤ 1.0)

Returns:

  • Float16: The arc sine function value of the input parameter, in radians, is returned.

Throws:

  • IllegalArgumentException: When the value of parameter x is greater than 1.0 or less than –1.0, this exception is thrown.

Examples:

import std.math.asin

main() {
    let n: Float16 = 0.0
    let asin = asin(n)
    println(asin)
}

Results:

0.000000

Examples of Throws:

import std.math.asin

main(): Unit {
    let n = 1.4
    let asin = asin(n)
    println(asin)
}

func asin(Float32)

public func asin(x: Float32): Float32

Description: Obtains the arc sine function value of a single-precision floating-point number through calculation.

Parameters:

  • x: Float32: single-precision floating-point number input (–1.0 ≤ x ≤ 1.0)

Returns:

  • Float32: The arc sine function value of the input parameter, in radians, is returned.

Throws:

  • IllegalArgumentException: When the value of parameter x is greater than 1.0 or less than –1.0, this exception is thrown.

Examples:

import std.math.asin

main() {
    let n: Float32 = 0.0
    let asin = asin(n)
    println(asin)
}

Results:

0.000000

func asin(Float64)

public func asin(x: Float64): Float64

Description: Obtains the arc sine function value of a double-precision floating-point number through calculation.

Parameters:

  • x: Float64: double-precision floating-point number input (–1.0 ≤ x ≤ 1.0)

Returns:

  • Float64: The arc sine function value of the input parameter, in radians, is returned.

Throws:

  • IllegalArgumentException: When the value of parameter x is greater than 1.0 or less than –1.0, this exception is thrown.

Examples:

import std.math.asin

main() {
    let n: Float64 = 0.0
    let asin = asin(n)
    println(asin)
}

Results:

0.000000

func asinh(Float16)

public func asinh(x: Float16): Float16

Description: Obtains the inverse hyperbolic sine function value of a half-precision floating-point number through calculation.

Parameters:

  • x: Float16: half-precision floating-point number input

Returns:

  • Float16: The inverse hyperbolic sine function value of the input parameter is returned.

Examples:

import std.math.asinh

main() {
    let n: Float16 = 0.0
    let asinh = asinh(n)
    println(asinh)
}

Results:

0.000000

func asinh(Float32)

public func asinh(x: Float32): Float32

Description: Obtains the inverse hyperbolic sine function value of a single-precision floating-point number through calculation.

Parameters:

  • x: Float32: single-precision floating-point number input

Returns:

  • Float32: The inverse hyperbolic sine function value of the input parameter is returned.

Examples:

import std.math.asinh

main() {
    let n: Float32 = 0.0
    let asinh = asinh(n)
    println(asinh)
}

Results:

0.000000

func asinh(Float64)

public func asinh(x: Float64): Float64

Description: Obtains the inverse hyperbolic sine function value of a double-precision floating-point number through calculation.

Parameters:

  • x: Float64: double-precision floating-point number input

Returns:

  • Float64: The inverse hyperbolic sine function value of the input parameter is returned.

Examples:

import std.math.asinh

main() {
    let n: Float64 = 0.0
    let asinh = asinh(n)
    println(asinh)
}

Results:

0.000000

func atan(Float16)

public func atan(x: Float16): Float16

Description: Obtains the arc tangent function value of a half-precision floating-point number through calculation.

Parameters:

  • x: Float16: half-precision floating-point number input

Returns:

  • Float16: The arc tangent function value of the input parameter, in radians, is returned.

Examples:

import std.math.atan

main() {
    let n: Float16 = 0.0
    let atan = atan(n)
    println(atan)
}

Results:

0.000000

func atan(Float32)

public func atan(x: Float32): Float32

Description: Obtains the arc tangent function value of a single-precision floating-point number through calculation.

Parameters:

  • x: Float32: single-precision floating-point number input

Returns:

  • Float32: The arc tangent function value of the input parameter, in radians, is returned.

Examples:

import std.math.atan

main() {
    let n: Float32 = 0.0
    let atan = atan(n)
    println(atan)
}

Results:

0.000000

func atan(Float64)

public func atan(x: Float64): Float64

Description: Obtains the arc tangent function value of a double-precision floating-point number through calculation.

Parameters:

  • x: Float64: double-precision floating-point number input

Returns:

  • Float64: The arc tangent function value of the input parameter, in radians, is returned.

Examples:

import std.math.atan

main() {
    let n: Float64 = 0.0
    let atan = atan(n)
    println(atan)
}

Results:

0.000000

func atan2(Float16, Float16)

public func atan2(y: Float16, x: Float16): Float16

Description: Obtains the arc tangent function value y/x of two half-precision floating-point numbers through calculation, in radians.

Parameters:

  • y: Float16: half-precision floating-point number input
  • x: Float16: half-precision floating-point number input

Returns:

  • Float16: arc tangent function value y/x, in radians

Examples:

import std.math.*
import std.convert.Formattable

main() {
    let y: Float16 = 1.0
    let x: Float16 = 1.0
    let atan2 = atan2(y, x) / Float16.getPI() * 180.0 // Convert the radian value into an angle value.
    println("${atan2.format(".1")}°")
}

Results:

45.0°

func atan2(Float32, Float32)

public func atan2(y: Float32, x: Float32): Float32

Description: Obtains the arc tangent function value y/x of two single-precision floating-point numbers through calculation, in radians.

Parameters:

  • y: Float32: single-precision floating-point number input
  • x: Float32: single-precision floating-point number input

Returns:

  • Float32: arc tangent function value y/x, in radians

Examples:

import std.math.*
import std.convert.Formattable

main() {
    let y: Float32 = 1.0
    let x: Float32 = 1.0
    let atan2 = atan2(y, x) / Float32.getPI() * 180.0 // Convert the radian value into an angle value.
    println("${atan2.format(".1")}°")
}

Results:

45.0°

func atan2(Float64, Float64)

public func atan2(y: Float64, x: Float64): Float64

Description: Obtains the arc tangent function value y/x of two double-precision floating-point numbers through calculation, in radians.

Parameters:

  • y: Float64: double-precision floating-point number input
  • x: Float64: double-precision floating-point number input

Returns:

  • Float64: arc tangent function value y/x, in radians

Examples:

import std.math.*
import std.convert.Formattable

main() {
    let y: Float64 = 1.0
    let x: Float64 = 1.0
    let atan2 = atan2(y, x) / Float64.getPI() * 180.0 // Convert the radian value into an angle value.
    println("${atan2.format(".1")}°")
}

Results:

45.0°

func atanh(Float16)

public func atanh(x: Float16): Float16

Description: Obtains the inverse hyperbolic tangent function value of a half-precision floating-point number through calculation.

Parameters:

  • x: Float16: half-precision floating-point number input (–1.0 < <idp:inline displayname="code" id="office_0fcbbb77-0be7-41d0-8fee-614748367052" tempcmdid="office_0fcbbb77-0be7-41d0-8fee-614748367052">x</idp:inline> < 1.0)

Returns:

  • Float16: The inverse hyperbolic tangent function value of the input parameter is returned.

Throws:

  • IllegalArgumentException: When the value of parameter x is greater than or equal to 1.0 or is less than or equal to –1.0, this exception is thrown.

Examples:

import std.math.atanh

main() {
    let n: Float16 = 0.0
    let atanh = atanh(n)
    println(atanh)
}

Results:

0.000000

Examples of Throws:

import std.math.atanh

main(): Unit {
    let n = -1.4
    let atanh = atanh(n)
    println(atanh)
}

func atanh(Float32)

public func atanh(x: Float32): Float32

Description: Obtains the inverse hyperbolic tangent function value of a single-precision floating-point number through calculation.

Parameters:

  • x: Float32: single-precision floating-point number input (–1.0 < x < 1.0)

Returns:

  • Float32: The inverse hyperbolic tangent function value of the input parameter is returned.

Throws:

  • IllegalArgumentException: When the value of parameter x is greater than or equal to 1.0 or is less than or equal to –1.0, this exception is thrown.

Examples:

import std.math.atanh

main() {
    let n: Float32 = 0.0
    let atanh = atanh(n)
    println(atanh)
}

Results:

0.000000

func atanh(Float64)

public func atanh(x: Float64): Float64

Description: Obtains the inverse hyperbolic tangent function value of a double-precision floating-point number through calculation.

Parameters:

  • x: Float64: double-precision floating-point number input (–1.0 < x < 1.0)

Returns:

  • Float64: The inverse hyperbolic tangent function value of the input parameter is returned.

Throws:

  • IllegalArgumentException: When the value of parameter x is greater than or equal to 1.0 or is less than or equal to –1.0, this exception is thrown.

Examples:

import std.math.atanh

main() {
    let n: Float64 = 0.0
    let atanh = atanh(n)
    println(atanh)
}

Results:

0.000000

func cbrt(Float16)

public func cbrt(x: Float16): Float16

Description: Obtains the cube root of a half-precision floating-point number.

Parameters:

  • x: Float16: half-precision floating-point number input

Returns:

  • Float16: The cube root of the input parameter is returned.

Examples:

import std.math.cbrt

main() {
    let n: Float16 = -1000.0
    let cbrt = cbrt(n)
    println(cbrt)
}

Results:

-10.000000

func cbrt(Float32)

public func cbrt(x: Float32): Float32

Description: Obtains the cube root of a single-precision floating-point number.

Parameters:

  • x: Float32: single-precision floating-point number input

Returns:

  • Float32: The cube root of the input parameter is returned.

Examples:

import std.math.cbrt

main() {
    let n: Float32 = -1000.0
    let cbrt = cbrt(n)
    println(cbrt)
}

Results:

-10.000000

func cbrt(Float64)

public func cbrt(x: Float64): Float64

Description: Obtains the cube root of a double-precision floating-point number.

Parameters:

  • x: Float64: double-precision floating-point number input

Returns:

  • Float64: The cube root of the input parameter is returned.

Examples:

import std.math.cbrt

main() {
    let n: Float64 = -1000.0
    let cbrt = cbrt(n)
    println(cbrt)
}

Results:

-10.000000

func ceil(Float16)

public func ceil(x: Float16): Float16

Description: Obtains the rounded-up value of a half-precision floating-point number.

Parameters:

  • x: Float16: half-precision floating-point number input

Returns:

  • Float16: The rounded-up value of the input parameter is returned.

Examples:

import std.math.ceil

main() {
    let n: Float16 = 0.7
    let ceil = ceil(n)
    println(ceil)
}

Results:

1.000000

func ceil(Float32)

public func ceil(x: Float32): Float32

Description: Obtains the rounded-up value of a single-precision floating-point number.

Parameters:

  • x: Float32: single-precision floating-point number input

Returns:

  • Float32: The rounded-up value of the input parameter is returned.

Examples:

import std.math.ceil

main() {
    let n: Float32 = 0.7
    let ceil = ceil(n)
    println(ceil)
}

Results:

1.000000

func ceil(Float64)

public func ceil(x: Float64): Float64

Description: Obtains the rounded-up value of a double-precision floating-point number.

Parameters:

  • x: Float64: double-precision floating-point number input

Returns:

  • Float64: The rounded-up value of the input parameter is returned.

Examples:

import std.math.ceil

main() {
    let n: Float64 = 0.7
    let ceil = ceil(n)
    println(ceil)
}

Results:

1.000000

func checkedAbs(Int16)

public func checkedAbs(x: Int16): Option<Int16>

Description: Obtains the absolute value of a 16-bit signed integer. If the input parameter is the minimum value of the 16-bit signed integer, the function returns None. Otherwise, the function returns Some(abs(x)).

Parameters:

  • x: Int16: 16-bit signed integer input

Returns:

  • Option<Int16>: The option type of the absolute value of the input parameter is returned.

Examples:

import std.math.checkedAbs

main() {
    let n: Int16 = -23
    let checkedAbs = checkedAbs(n)
    println(checkedAbs)
}

Results:

Some(23)

func checkedAbs(Int32)

public func checkedAbs(x: Int32): Option<Int32>

Description: Obtains the absolute value of a 32-bit signed integer. If the input parameter is the minimum value of the 32-bit signed integer, the function returns None. Otherwise, the function returns Some(abs(x)).

Parameters:

  • x: Int32: 32-bit signed integer input

Returns:

  • Option<Int32>: The option type of the absolute value of the input parameter is returned.

Examples:

import std.math.checkedAbs

main() {
    let n: Int32 = -23
    let checkedAbs = checkedAbs(n)
    println(checkedAbs)
}

Results:

Some(23)

func checkedAbs(Int64)

public func checkedAbs(x: Int64): Option<Int64>

Description: Obtains the absolute value of a 64-bit signed integer. If the input parameter is the minimum value of the 64-bit signed integer, the function returns None. Otherwise, the function returns Some(abs(x)).

Parameters:

  • x: Int64: 64-bit signed integer input

Returns:

  • Option<Int64>: The option type of the absolute value of the input parameter is returned.

Examples:

import std.math.checkedAbs

main() {
    let n: Int64 = -23
    let checkedAbs = checkedAbs(n)
    println(checkedAbs)
}

Results:

Some(23)

func checkedAbs(Int8)

public func checkedAbs(x: Int8): Option<Int8>

Description: Obtains the absolute value of an 8-bit signed integer. If the input parameter is the minimum value of the 8-bit signed integer, the function returns None. Otherwise, the function returns Some(abs(x)).

Parameters:

  • x: Int8: 8-bit signed integer input

Returns:

  • Option<Int8>: The option type of the absolute value of the input parameter is returned.

Examples:

import std.math.checkedAbs

main() {
    let n: Int8 = -23
    let checkedAbs = checkedAbs(n)
    println(checkedAbs)
}

Results:

Some(23)

func clamp(Float16, Float16, Float16)

public func clamp(v: Float16, min: Float16, max: Float16): Float16

Description: Obtains the value of a floating-point number to which the clamp function with a given range is applied. If the floating-point number is within the range, the floating-point number is returned. If the floating-point number is less than the minimum value in the range, the minimum value is returned. If the floating-point number is greater than the maximum value in the range, the maximum value is returned. If the floating-point number is NaN, NaN is returned.

Parameters:

  • v: Float16: floating-point number input
  • min: Float16: specified minimum value
  • max: Float16: specified maximum value

Returns:

  • Float16: If v is between min and max, v is returned. If v is less than or equal to min, min is returned. If v is greater than or equal to max, max is returned. If v is NaN, NaN is returned.

Throws:

  • IllegalArgumentException: If the value of min is greater than that of max or min and max are NaN, this exception is thrown.

Examples:

import std.math.clamp

main() {
    let n: Float16 = -23.0
    let clamp = clamp(n, -100.0, 100.0)
    println(clamp)
}

Results:

-23.000000

func clamp(Float32, Float32, Float32)

public func clamp(v: Float32, min: Float32, max: Float32): Float32

Description: Obtains the value of a floating-point number to which the clamp function with a given range is applied. If the floating-point number is within the range, the floating-point number is returned. If the floating-point number is less than the minimum value in the range, the minimum value is returned. If the floating-point number is greater than the maximum value in the range, the maximum value is returned. If the floating-point number is NaN, NaN is returned.

Parameters:

  • v: Float32: floating-point number input
  • min: Float32: specified minimum value
  • max: Float32: specified maximum value

Returns:

  • Float32: If v is between min and max, v is returned. If v is less than or equal to min, min is returned. If v is greater than or equal to max, max is returned. If v is NaN, NaN is returned.

Throws:

  • IllegalArgumentException: If the value of min is greater than that of max or min and max are NaN, this exception is thrown.

Examples:

import std.math.clamp

main() {
    var m: Float32 = -23.0
    var clamp1 = clamp(m, -100.0, 100.0)
    println(clamp1)

    var n: Float32 = -123.0
    var clamp2 = clamp(n, -100.0, 100.0)
    println(clamp2)

    var p: Float32 = 123.0
    var clamp3 = clamp(p, -100.0, 100.0)
    println(clamp3)
}

Results:

-23.000000
-100.000000
100.000000

func clamp(Float64, Float64, Float64)

public func clamp(v: Float64, min: Float64, max: Float64): Float64

Description: Obtains the value of a floating-point number to which the clamp function with a given range is applied. If the floating-point number is within the range, the floating-point number is returned. If the floating-point number is less than the minimum value in the range, the minimum value is returned. If the floating-point number is greater than the maximum value in the range, the maximum value is returned. If the floating-point number is NaN, NaN is returned.

Parameters:

  • v: Float64: floating-point number input
  • min: Float64: specified minimum value
  • max: Float64: specified maximum value

Returns:

  • Float64: If v is between min and max, v is returned. If v is less than or equal to min, min is returned. If v is greater than or equal to max, max is returned. If v is NaN, NaN is returned.

Throws:

  • IllegalArgumentException: If the value of min is greater than that of max or min and max are NaN, this exception is thrown.

Examples:

import std.math.clamp

main() {
    let n: Float64 = -23.0
    let clamp = clamp(n, -100.0, 100.0)
    println(clamp)
}

Results:

-23.000000

func cos(Float16)

public func cos(x: Float16): Float16

Description: Obtains the cosine function value of a half-precision floating-point number through calculation.

Parameters:

  • x: Float16: half-precision floating-point number input, in radians

Returns:

  • Float16: The cosine function value of the input parameter is returned.

Examples:

import std.math.cos

main() {
    let n: Float16 = 3.14159265
    let cos = cos(n)
    println(cos)
}

Results:

-1.000000

func cos(Float32)

public func cos(x: Float32): Float32

Description: Obtains the cosine function value of a single-precision floating-point number through calculation.

Parameters:

  • x: Float32: single-precision floating-point number input, in radians

Returns:

  • Float32: The cosine function value of the input parameter is returned.

Examples:

import std.math.cos

main() {
    let n: Float32 = 3.14159265
    let cos = cos(n)
    println(cos)
}

Results:

-1.000000

func cos(Float64)

public func cos(x: Float64): Float64

Description: Obtains the cosine function value of a double-precision floating-point number through calculation.

Parameters:

  • x: Float64: double-precision floating-point number input, in radians

Returns:

  • Float64: The cosine function value of the input parameter is returned.

Examples:

import std.math.cos

main() {
    let n: Float64 = 3.14159265
    let cos = cos(n)
    println(cos)
}

Results:

-1.000000

func cosh(Float16)

public func cosh(x: Float16): Float16

Description: Obtains the hyperbolic cosine function value of a half-precision floating-point number through calculation.

Parameters:

  • x: Float16: half-precision floating-point number input

Returns:

  • Float16: The hyperbolic cosine function value of the input parameter is returned.

Examples:

import std.math.cosh

main() {
    let n: Float16 = 0.0
    let cosh = cosh(n)
    println(cosh)
}

Results:

1.000000

func cosh(Float32)

public func cosh(x: Float32): Float32

Description: Obtains the hyperbolic cosine function value of a single-precision floating-point number through calculation.

Parameters:

  • x: Float32: single-precision floating-point number input

Returns:

  • Float32: The hyperbolic cosine function value of the input parameter is returned.

Examples:

import std.math.cosh

main() {
    let n: Float32 = 0.0
    let cosh = cosh(n)
    println(cosh)
}

Results:

1.000000

func cosh(Float64)

public func cosh(x: Float64): Float64

Description: Obtains the hyperbolic cosine function value of a double-precision floating-point number through calculation.

Parameters:

  • x: Float64: double-precision floating-point number input

Returns:

  • Float64: The hyperbolic cosine function value of the input parameter is returned.

Examples:

import std.math.cosh

main() {
    let n: Float64 = 0.0
    let cosh = cosh(n)
    println(cosh)
}

Results:

1.000000

func countOne(Int16) (deprecated)

public func countOne(x: Int16): Int8

Description: Obtains the number of 1s in the binary expression of a 16-bit integer.

NOTE

This function will be deprecated in future releases and countOnes(Int16) will be used instead.

Parameters:

  • x: Int16: 16-bit signed integer input

Returns:

  • Int8: The number of bits of 1s in the binary representation of the input parameter is returned.

func countOnes(Int16)

public func countOnes(x: Int16): Int64

Description: Obtains the number of 1s in the binary expression of a 16-bit integer.

Parameters:

  • x: Int16: 16-bit signed integer input

Returns:

  • Int64: number of bits of 1s in the binary representation of the input parameter

Examples:

import std.math.countOnes

main() {
    let n: Int16 = 15
    let countOnes = countOnes(n)
    println(countOnes)
}

Results:

4

func countOne(Int32) (deprecated)

public func countOne(x: Int32): Int8

Description: Obtains the number of 1s in the binary expression of a 32-bit integer.

NOTE

This function will be deprecated in future releases and countOnes(Int32) will be used instead.

Parameters:

  • x: Int32: 32-bit signed integer input

Returns:

  • Int8: The number of bits of 1s in the binary representation of the input parameter is returned.

func countOnes(Int32)

public func countOnes(x: Int32): Int64

Description: Obtains the number of 1s in the binary expression of a 32-bit integer.

Parameters:

  • x: Int32: 32-bit signed integer input

Returns:

  • Int64: number of bits of 1s in the binary representation of the input parameter

Examples:

import std.math.countOnes

main() {
    let n: Int32 = 15
    let countOnes = countOnes(n)
    println(countOnes)
}

Results:

4

func countOne(Int64) (deprecated)

public func countOne(x: Int64): Int8

Description: Obtains the number of 1s in the binary expression of a 64-bit integer.

NOTE

This function will be deprecated in future releases and countOnes(Int64) will be used instead.

Parameters:

  • x: Int64: 64-bit signed integer input

Returns:

  • Int8: The number of bits of 1s in the binary representation of the input parameter is returned.

func countOnes(Int64)

public func countOnes(x: Int64): Int64

Description: Obtains the number of 1s in the binary expression of a 64-bit integer.

Parameters:

  • x: Int64: 64-bit signed integer input

Returns:

  • Int64: number of bits of 1s in the binary representation of the input parameter

Examples:

import std.math.countOnes

main() {
    let n: Int64 = 15
    let countOnes = countOnes(n)
    println(countOnes)
}

Results:

4

func countOne(Int8) (deprecated)

public func countOne(x: Int8): Int8

Description: Obtains the number of 1s in the binary expression of an 8-bit integer.

NOTE

This function will be deprecated in future releases and countOnes(Int8) will be used instead.

Parameters:

  • x: Int8: 8-bit signed integer input

Returns:

  • Int8: The number of bits of 1s in the binary representation of the input parameter is returned.

func countOnes(Int8)

public func countOnes(x: Int8): Int64

Description: Obtains the number of 1s in the binary expression of an 8-bit integer.

Parameters:

  • x: Int8: 8-bit signed integer input

Returns:

  • Int64: number of bits of 1s in the binary representation of the input parameter

Examples:

import std.math.countOnes

main() {
    let n: Int8 = 15
    let countOnes = countOnes(n)
    println(countOnes)
}

Results:

4

func countOne(UInt16) (deprecated)

public func countOne(x: UInt16): Int8

Description: Obtains the number of bits of 1s in the binary expression of a 16-bit unsigned integer.

NOTE

This function will be deprecated in future releases and countOnes(UInt16) will be used instead.

Parameters:

  • x: UInt16: 16-bit unsigned integer input

Returns:

  • Int8: The number of bits of 1s in the binary representation of the input parameter is returned.

func countOnes(UInt16)

public func countOnes(x: UInt16): Int64

Description: Obtains the number of bits of 1s in the binary expression of a 16-bit unsigned integer.

Parameters:

  • x: UInt16: 16-bit unsigned integer input

Returns:

  • Int64: number of bits of 1s in the binary representation of the input parameter

Examples:

import std.math.countOnes

main() {
    let n: UInt16 = 15
    let countOnes = countOnes(n)
    println(countOnes)
}

Results:

4

func countOne(UInt32) (deprecated)

public func countOne(x: UInt32): Int8

Description: Obtains the number of bits of 1s in the binary expression of a 32-bit unsigned integer.

NOTE

This function will be deprecated in future releases and countOnes(UInt32) will be used instead.

Parameters:

  • x: UInt32: 32-bit unsigned integer input

Returns:

  • Int8: The number of bits of 1s in the binary representation of the input parameter is returned.

func countOnes(UInt32)

public func countOnes(x: UInt32): Int64

Description: Obtains the number of bits of 1s in the binary expression of a 32-bit unsigned integer.

Parameters:

  • x: UInt32: 32-bit unsigned integer input

Returns:

  • Int64: number of bits of 1s in the binary representation of the input parameter

Examples:

import std.math.countOnes

main() {
    let n: UInt32 = 15
    let countOnes = countOnes(n)
    println(countOnes)
}

Results:

4

func countOne(UInt64) (deprecated)

public func countOne(x: UInt64): Int8

Description: Obtains the number of bits of 1s in the binary expression of a 64-bit unsigned integer.

NOTE

This function will be deprecated in future releases and countOnes(UInt64) will be used instead.

Parameters:

  • x: UInt64: 64-bit unsigned integer input

Returns:

  • Int8: The number of bits of 1s in the binary representation of the input parameter is returned.

func countOnes(UInt64)

public func countOnes(x: UInt64): Int64

Description: Obtains the number of bits of 1s in the binary expression of a 64-bit unsigned integer.

Parameters:

  • x: UInt64: 64-bit unsigned integer input

Returns:

  • Int64: number of bits of 1s in the binary representation of the input parameter

Examples:

import std.math.countOnes

main() {
    let n: UInt64 = 15
    let countOnes = countOnes(n)
    println(countOnes)
}

Results:

4

func countOne(UInt8) (deprecated)

public func countOne(x: UInt8): Int8

Description: Obtains the number of bits of 1s in the binary expression of an 8-bit unsigned integer.

NOTE

This function will be deprecated in future releases and countOnes(UInt8) will be used instead.

Parameters:

  • x: UInt8: 8-bit unsigned integer input

Returns:

  • Int8: The number of bits of 1s in the binary representation of the input parameter is returned.

func countOnes(UInt8)

public func countOnes(x: UInt8): Int64

Description: Obtains the number of bits of 1s in the binary expression of an 8-bit unsigned integer.

Parameters:

  • x: UInt8: 8-bit unsigned integer input

Returns:

  • Int64: number of bits of 1s in the binary representation of the input parameter

Examples:

import std.math.countOnes

main() {
    let n: UInt8 = 15
    let countOnes = countOnes(n)
    println(countOnes)
}

Results:

4

func erf(Float16)

public func erf(x: Float16): Float16

Description: Obtains the error value of a half-precision floating-point number. Related definition: $$erf(x) = \frac{2}{\sqrt{\pi}}\int_0^xe^{-t^2}dt$$

Parameters:

  • x: Float16: half-precision floating-point number input

Returns:

  • Float16: The error value of the half-precision floating-point number of the input parameter is returned.

Examples:

import std.math.erf

main() {
    let n: Float16 = 5.0
    let erf = erf(n)
    println(erf)
}

Results:

1.000000

func erf(Float32)

public func erf(x: Float32): Float32

Description: Obtains the error value of a single-precision floating-point number. Related definition: $$erf(x) = \frac{2}{\sqrt{\pi}}\int_0^xe^{-t^2}dt$$

Parameters:

  • x: Float32: single-precision floating-point number input

Returns:

  • Float32: The error value of the single-precision floating-point number of the input parameter is returned.

Examples:

import std.math.erf

main() {
    let n: Float32 = 5.0
    let erf = erf(n)
    println(erf)
}

Results:

1.000000

func erf(Float64)

public func erf(x: Float64): Float64

Description: Obtains the error value of a double-precision floating-point number. Related definition: $$erf(x) = \frac{2}{\sqrt{\pi}}\int_0^xe^{-t^2}dt$$

Parameters:

  • x: Float64: double-precision floating-point number input

Returns:

  • Float64: The error value of the double-precision floating-point number of the input parameter is returned.

Examples:

import std.math.erf

main() {
    let n: Float64 = 5.0
    let erf = erf(n)
    println(erf)
}

Results:

1.000000

func exp(Float16)

public func exp(x: Float16): Float16

Description: Obtains the natural constant e raised to the power of x.

Parameters:

  • x: Float16: half-precision floating-point number exponent input

Returns:

  • Float16: The natural constant e raised to the power of x is returned.

Examples:

import std.math.exp

main() {
    let n: Float16 = 1.0
    let exp = exp(n)
    println(exp)
}

Results:

2.718750

func exp(Float32)

public func exp(x: Float32): Float32

Description: Obtains the natural constant e raised to the power of x.

Parameters:

  • x: Float32: single-precision floating-point number exponent input

Returns:

  • Float32: The natural constant e raised to the power of x is returned.

Examples:

import std.math.exp

main() {
    let n: Float32 = 1.0
    let exp = exp(n)
    println(exp)
}

Results:

2.718282

func exp(Float64)

public func exp(x: Float64): Float64

Description: Obtains the natural constant e raised to the power of x.

Parameters:

  • x: Float64: double-precision floating-point number exponent input

Returns:

  • Float64: The natural constant e raised to the power of x is returned.

Examples:

import std.math.exp

main() {
    let n: Float64 = 1.0
    let exp = exp(n)
    println(exp)
}

Results:

2.718282

func exp2(Float16)

public func exp2(x: Float16): Float16

Description: Obtains 2 raised to the power of x.

Parameters:

  • x: Float16: half-precision floating-point number exponent input

Returns:

  • Float16: 2 raised to the power of x is returned.

Examples:

import std.math.exp2

main() {
    let n: Float16 = 10.0
    let exp2 = exp2(n)
    println(exp2)
}

Results:

1024.000000

func exp2(Float32)

public func exp2(x: Float32): Float32

Description: Obtains 2 raised to the power of x.

Parameters:

  • x: Float32: single-precision floating-point number exponent input

Returns:

  • Float32: 2 raised to the power of x is returned.

Examples:

import std.math.exp2

main() {
    let n: Float32 = 10.0
    let exp2 = exp2(n)
    println(exp2)
}

Results:

1024.000000

func exp2(Float64)

public func exp2(x: Float64): Float64

Description: Obtains 2 raised to the power of x.

Parameters:

  • x: Float64: double-precision floating-point number exponent input

Returns:

  • Float64: 2 raised to the power of x is returned.

Examples:

import std.math.exp2

main() {
    let n: Float64 = 10.0
    let exp = exp2(n)
    println(exp)
}

Results:

1024.000000

func floor(Float16)

public func floor(x: Float16): Float16

Description: Obtains the rounded-down value of a floating-point number.

Parameters:

  • x: Float16: half-precision floating-point number input to be rounded down

Returns:

  • Float16: The rounded-down value of the input floating-point number is returned.

Examples:

import std.math.floor

main() {
    let n: Float16 = 10.5
    let floor = floor(n)
    println(floor)
}

Results:

10.000000

func floor(Float32)

public func floor(x: Float32): Float32

Description: Obtains the rounded-down value of a floating-point number.

Parameters:

  • x: Float32: single-precision floating-point number input to be rounded down

Returns:

  • Float32: The rounded-down value of the input floating-point number is returned.

Examples:

import std.math.floor

main() {
    let n: Float32 = 10.5
    let floor = floor(n)
    println(floor)
}

Results:

10.000000

func floor(Float64)

public func floor(x: Float64): Float64

Description: Obtains the rounded-down value of a floating-point number.

Parameters:

  • x: Float64: double-precision floating-point number input to be rounded down

Returns:

  • Float64: The rounded-down value of the input floating-point number is returned.

Examples:

import std.math.floor

main() {
    let n: Float64 = 10.5
    let floor = floor(n)
    println(floor)
}

Results:

10.000000

func fmod(Float16, Float16)

public func fmod(x: Float16, y: Float16): Float16

Description: Obtains the remainder of the division x/y of two half-precision floating-point numbers through calculation.

Parameters:

Returns:

  • Float16: remainder of x/y. If x or y is NaN, NaN is returned.

Throws:

Examples:

import std.math.fmod
import std.convert.Formattable

main() {
    let x: Float16 = 3.3
    let y: Float16 = 2.2
    let fmod = fmod(x, y)
    println(fmod.format(".1"))
}

Results:

1.1

func fmod(Float32, Float32)

public func fmod(x: Float32, y: Float32): Float32

Description: Obtains the remainder of the division x/y of two single-precision floating-point numbers through calculation.

Parameters:

Returns:

  • Float32: remainder of x/y. If x or y is NaN, NaN is returned.

Throws:

Examples:

import std.math.fmod
import std.convert.Formattable

main() {
    let x: Float32 = 3.3
    let y: Float32 = 2.2
    let fmod = fmod(x, y)
    println(fmod.format(".1"))
}

Results:

1.1

func fmod(Float64, Float64)

public func fmod(x: Float64, y: Float64): Float64

Description: Obtains the remainder of the division x/y of two double-precision floating-point numbers through calculation.

Parameters:

Returns:

  • Float64: remainder of x/y. If x or y is NaN, NaN is returned.

Throws:

Examples:

import std.math.fmod
import std.convert.Formattable

main() {
    let x: Float64 = 3.3
    let y: Float64 = 2.2
    let fmod = fmod(x, y)
    println(fmod.format(".1"))
}

Results:

1.1

func gamma(Float16)

public func gamma(x: Float16): Float16

Description: Obtains the gamma function value of a floating-point number. This function is a generalization of the factorial concept on real numbers. Its evaluation formula is as follows:

$${\displaystyle \Gamma (x)=\int _{0}^{\infty }t^{x-1}\mathrm {e} ^{-t}{\rm {{d}t,}}}$$

Parameters:

  • x: Float16: half-precision floating-point number input whose gamma function value is to be obtained

Returns:

  • Float16: The gamma function value of the input floating-point number is returned.

Examples:

import std.math.gamma

main() {
    let n: Float16 = -1.1
    let gamma = gamma(n)
    println(gamma)
}

Results:

9.750000

func gamma(Float32)

public func gamma(x: Float32): Float32

Description: Obtains the gamma function value of a floating-point number. This function is a generalization of the factorial concept on real numbers.

Parameters:

  • x: Float32: single-precision floating-point number input whose gamma function value is to be obtained

Returns:

  • Float32: The gamma function value of the input floating-point number is returned.

Examples:

import std.math.gamma

main() {
    let n: Float32 = -1.1
    let gamma = gamma(n)
    println(gamma)
}

Results:

9.714804

func gamma(Float64)

public func gamma(x: Float64): Float64

Description: Obtains the gamma function value of a floating-point number. This function is a generalization of the factorial concept on real numbers.

Parameters:

  • x: Float64: double-precision floating-point number input whose gamma function value is to be obtained

Returns:

  • Float64: The gamma function value of the input floating-point number is returned.

Examples:

import std.math.gamma

main() {
    let n: Float64 = -1.1
    let gamma = gamma(n)
    println(gamma)
}

Results:

9.714806

func gcd(Int16, Int16)

public func gcd(x: Int16, y: Int16): Int16

Description: Obtains the greatest common divisor of two 16-bit signed integers.

Parameters:

  • x: Int16: one input integer for the greatest common divisor calculation
  • y: Int16: the other input integer for the greatest common divisor calculation

Returns:

  • Int16: The greatest common divisor of the two integers is returned.

Throws:

  • IllegalArgumentException: When both parameters are the minimum value of a signed integer, or when one parameter is the minimum value of a signed integer and the other parameter is 0, this exception is thrown.

Examples:

import std.math.gcd

main() {
    let x: Int16 = 15
    let y: Int16 = 9
    let gcd = gcd(x, y)
    println(gcd)
}

Results:

3

func gcd(Int32, Int32)

public func gcd(x: Int32, y: Int32): Int32

Description: Obtains the greatest common divisor of two 32-bit signed integers.

Parameters:

  • x: Int32: one input integer for the greatest common divisor calculation
  • y: Int32: the other input integer for the greatest common divisor calculation

Returns:

  • Int32: The greatest common divisor of the two integers is returned.

Throws:

  • IllegalArgumentException: When both parameters are the minimum value of a signed integer, or when one parameter is the minimum value of a signed integer and the other parameter is 0, this exception is thrown.

Examples:

import std.math.gcd

main() {
    let x: Int32 = 15
    let y: Int32 = 9
    let gcd = gcd(x, y)
    println(gcd)
}

Results:

3

func gcd(Int64, Int64)

public func gcd(x: Int64, y: Int64): Int64

Description: Obtains the greatest common divisor of two 64-bit signed integers.

Parameters:

  • x: Int64: one input integer for the greatest common divisor calculation
  • y: Int64: the other input integer for the greatest common divisor calculation

Returns:

  • Int64: The greatest common divisor of the two integers is returned.

Throws:

  • IllegalArgumentException: When both parameters are the minimum value of a signed integer, or when one parameter is the minimum value of a signed integer and the other parameter is 0, this exception is thrown.

Examples:

import std.math.gcd

main() {
    let x: Int64 = 15
    let y: Int64 = 9
    let gcd = gcd(x, y)
    println(gcd)
}

Results:

3

func gcd(Int8, Int8)

public func gcd(x: Int8, y: Int8): Int8

Description: Obtains the greatest common divisor of two 8-bit signed integers.

Parameters:

  • x: Int8: one input integer for the greatest common divisor calculation
  • y: Int8: the other input integer for the greatest common divisor calculation

Returns:

  • Int8: The greatest common divisor of the two integers is returned.

Throws:

  • IllegalArgumentException: When both parameters are the minimum value of a signed integer, or when one parameter is the minimum value of a signed integer and the other parameter is 0, this exception is thrown.

Examples:

import std.math.gcd

main() {
    let x: Int8 = 15
    let y: Int8= 9
    let gcd = gcd(x, y)
    println(gcd)
}

Results:

3

func gcd(UInt16, UInt16)

public func gcd(x: UInt16, y: UInt16): UInt16

Description: Obtains the greatest common divisor of two 16-bit unsigned integers.

Parameters:

  • x: UInt16: one input integer for the greatest common divisor calculation
  • y: UInt16: the other input integer for the greatest common divisor calculation

Returns:

  • UInt16: The greatest common divisor of the two integers is returned.

Examples:

import std.math.gcd

main() {
    let x: UInt16 = 15
    let y: UInt16 = 9
    let gcd = gcd(x, y)
    println(gcd)
}

Results:

3

func gcd(UInt32, UInt32)

public func gcd(x: UInt32, y: UInt32): UInt32

Description: Obtains the greatest common divisor of two 32-bit unsigned integers.

Parameters:

  • x: UInt32: one input integer for the greatest common divisor calculation
  • y: UInt32: the other input integer for the greatest common divisor calculation

Returns:

  • UInt32: The greatest common divisor of the two integers is returned.

Examples:

import std.math.gcd

main() {
    let x: UInt32 = 15
    let y: UInt32 = 9
    let gcd = gcd(x, y)
    println(gcd)
}

Results:

3

func gcd(UInt64, UInt64)

public func gcd(x: UInt64, y: UInt64): UInt64

Description: Obtains the greatest common divisor of two 64-bit unsigned integers.

Parameters:

  • x: UInt64: one input integer for the greatest common divisor calculation
  • y: UInt64: the other input integer for the greatest common divisor calculation

Returns:

  • UInt64: The greatest common divisor of the two integers is returned.

Examples:

import std.math.gcd

main() {
    let x: UInt64 = 15
    let y: UInt64 = 9
    let gcd = gcd(x, y)
    println(gcd)
}

Results:

3

func gcd(UInt8, UInt8)

public func gcd(x: UInt8, y: UInt8): UInt8

Description: Obtains the greatest common divisor of two 8-bit unsigned integers.

Parameters:

  • x: UInt8: one input integer for the greatest common divisor calculation
  • y: UInt8: the other input integer for the greatest common divisor calculation

Returns:

  • UInt8: The greatest common divisor of the two integers is returned.

Examples:

import std.math.gcd

main() {
    let x: UInt8 = 15
    let y: UInt8= 9
    let gcd = gcd(x, y)
    println(gcd)
}

Results:

3

func lcm(Int16, Int16)

public func lcm(x: Int16, y: Int16): Int16

Description: Obtains the non-negative least common multiple of two 16-bit signed integers. The value 0 is returned only when any input parameter is 0.

Parameters:

  • x: Int16: one input integer for the least common multiple calculation
  • y: Int16: the other input integer for the least common multiple calculation

Returns:

  • Int16: The non-negative least common multiple of the two integers is returned. The value 0 is returned only when any input parameter is 0.

Throws:

  • IllegalArgumentException: When the return value exceeds the maximum value of a 16-bit signed integer, this exception is thrown.

Examples:

import std.math.lcm

main() {
    let x: Int16 = -15
    let y: Int16 = 9
    let lcm = lcm(x, y)
    println(lcm)
}

Results:

45

func lcm(Int32, Int32)

public func lcm(x: Int32, y: Int32): Int32

Description: Obtains the non-negative least common multiple of two 32-bit signed integers. The value 0 is returned only when any input parameter is 0.

Parameters:

  • x: Int32: one input integer for the least common multiple calculation
  • y: Int32: the other input integer for the least common multiple calculation

Returns:

  • Int32: The non-negative least common multiple of the two integers is returned. The value 0 is returned only when any input parameter is 0.

Throws:

  • IllegalArgumentException: When the return value exceeds the maximum value of a 32-bit signed integer, this exception is thrown.

Examples:

import std.math.lcm

main() {
    let x: Int32 = -15
    let y: Int32 = 9
    let lcm = lcm(x, y)
    println(lcm)
}

Results:

45

func lcm(Int64, Int64)

public func lcm(x: Int64, y: Int64): Int64

Description: Obtains the non-negative least common multiple of two 64-bit signed integers. The value 0 is returned only when any input parameter is 0.

Parameters:

  • x: Int64: one input integer for the least common multiple calculation
  • y: Int64: the other input integer for the least common multiple calculation

Returns:

  • Int64: The non-negative least common multiple of the two integers is returned. The value 0 is returned only when any input parameter is 0.

Throws:

  • IllegalArgumentException: When the return value exceeds the maximum value of a 64-bit signed integer, this exception is thrown.

Examples:

import std.math.lcm

main() {
    let x: Int64 = 15
    let y: Int64 = 9
    let lcm = lcm(x, y)
    println(lcm)
}

Results:

45

func lcm(Int8, Int8)

public func lcm(x: Int8, y: Int8): Int8

Description: Obtains the non-negative least common multiple of two 8-bit signed integers. The value 0 is returned only when any input parameter is 0.

Parameters:

  • x: Int8: one input integer for the least common multiple calculation
  • y: Int8: the other input integer for the least common multiple calculation

Returns:

  • Int8: The non-negative least common multiple of the two integers is returned. The value 0 is returned only when any input parameter is 0.

Throws:

  • IllegalArgumentException: When the return value exceeds the maximum value of an 8-bit signed integer, this exception is thrown.

Examples:

import std.math.lcm

main() {
    let x: Int8 = 15
    let y: Int8= 9
    let lcm = lcm(x, y)
    println(lcm)
}

Results:

45

func lcm(UInt16, UInt16)

public func lcm(x: UInt16, y: UInt16): UInt16

Description: Obtains the non-negative least common multiple of two 16-bit unsigned integers. The value 0 is returned only when any input parameter is 0.

Parameters:

  • x: UInt16: one input integer for the least common multiple calculation
  • y: UInt16: the other input integer for the least common multiple calculation

Returns:

  • UInt16: The non-negative least common multiple of the two integers is returned. The value 0 is returned only when any input parameter is 0.

Throws:

  • IllegalArgumentException: When the return value exceeds the maximum value of a 16-bit unsigned integer, this exception is thrown.

Examples:

import std.math.lcm

main() {
    let x: UInt16 = 15
    let y: UInt16 = 9
    let lcm = lcm(x, y)
    println(lcm)
}

Results:

45

func lcm(UInt32, UInt32)

public func lcm(x: UInt32, y: UInt32): UInt32

Description: Obtains the non-negative least common multiple of two 32-bit unsigned integers. The value 0 is returned only when any input parameter is 0.

Parameters:

  • x: UInt32: one input integer for the least common multiple calculation
  • y: UInt32: the other input integer for the least common multiple calculation

Returns:

  • UInt32: The non-negative least common multiple of the two integers is returned. The value 0 is returned only when any input parameter is 0.

Throws:

  • IllegalArgumentException: When the return value exceeds the maximum value of a 32-bit unsigned integer, this exception is thrown.

Examples:

import std.math.lcm

main() {
    let x: UInt32 = 15
    let y: UInt32 = 9
    let lcm = lcm(x, y)
    println(lcm)
}

Results:

45

func lcm(UInt64, UInt64)

public func lcm(x: UInt64, y: UInt64): UInt64

Description: Obtains the non-negative least common multiple of two 64-bit unsigned integers. The value 0 is returned only when any input parameter is 0.

Parameters:

  • x: UInt64: one input integer for the least common multiple calculation
  • y: UInt64: the other input integer for the least common multiple calculation

Returns:

  • UInt64: The non-negative least common multiple of the two integers is returned. The value 0 is returned only when any input parameter is 0.

Throws:

  • IllegalArgumentException: When the return value exceeds the maximum value of a 64-bit unsigned integer, this exception is thrown.

Examples:

import std.math.lcm

main() {
    let x: UInt64 = 15
    let y: UInt64 = 9
    let lcm = lcm(x, y)
    println(lcm)
}

Results:

45

func lcm(UInt8, UInt8)

public func lcm(x: UInt8, y: UInt8): UInt8

Description: Obtains the non-negative least common multiple of two 8-bit unsigned integers. The value 0 is returned only when any input parameter is 0.

Parameters:

  • x: UInt8: one input integer for the least common multiple calculation
  • y: UInt8: the other input integer for the least common multiple calculation

Returns:

  • UInt8: The non-negative least common multiple of the two integers is returned. The value 0 is returned only when any input parameter is 0.

Throws:

  • IllegalArgumentException: When the return value exceeds the maximum value of an 8-bit unsigned integer, this exception is thrown.

Examples:

import std.math.lcm

main() {
    let x: UInt8 = 15
    let y: UInt8= 9
    let lcm = lcm(x, y)
    println(lcm)
}

Results:

45

func leadingZeros(Int16)

public func leadingZeros(x: Int16): Int64

Description: Obtains the number of consecutive 0s starting from the most significant bit in the binary expression of a 16-bit signed integer. If the most significant bit is not 0, the value 0 is returned.

Parameters:

  • x: Int16: integer of which the number of leading zeros is to be obtained

Returns:

  • Int64: The number of leading zeros is returned.

Examples:

import std.math.leadingZeros

main() {
    let x: Int16 = 512
    let leadingZeros = leadingZeros(x)
    println(leadingZeros)
}

Results:

6

func leadingZeros(Int32)

public func leadingZeros(x: Int32): Int64

Description: Obtains the number of consecutive 0s starting from the most significant bit in the binary expression of a 32-bit signed integer. If the most significant bit is not 0, the value 0 is returned.

Parameters:

  • x: Int32: integer of which the number of leading zeros is to be obtained

Returns:

  • Int64: The number of leading zeros is returned.

Examples:

import std.math.leadingZeros

main() {
    let x: Int32 = 512
    let leadingZeros = leadingZeros(x)
    println(leadingZeros)
}

Results:

22

func leadingZeros(Int64)

public func leadingZeros(x: Int64): Int64

Description: Obtains the number of consecutive 0s starting from the most significant bit in the binary expression of a 64-bit signed integer. If the most significant bit is not 0, the value 0 is returned.

Parameters:

  • x: Int64: integer of which the number of leading zeros is to be obtained

Returns:

  • Int64: The number of leading zeros is returned.

Examples:

import std.math.leadingZeros

main() {
    let x: Int64 = 512
    let leadingZeros = leadingZeros(x)
    println(leadingZeros)
}

Results:

54

func leadingZeros(Int8)

public func leadingZeros(x: Int8): Int64

Description: Obtains the number of consecutive 0s starting from the most significant bit in the binary expression of an 8-bit signed integer. If the most significant bit is not 0, the value 0 is returned.

Parameters:

  • x: Int8: integer of which the number of leading zeros is to be obtained

Returns:

  • Int64: The number of leading zeros is returned.

Examples:

import std.math.leadingZeros

main() {
    let x: Int8 = 4
    let leadingZeros = leadingZeros(x)
    println(leadingZeros)
}

Results:

5

func leadingZeros(UInt16)

public func leadingZeros(x: UInt16): Int64

Description: Obtains the number of consecutive 0s starting from the most significant bit in the binary expression of a 16-bit unsigned integer. If the most significant bit is not 0, the value 0 is returned.

Parameters:

  • x: UInt16: integer of which the number of leading zeros is to be obtained

Returns:

  • Int64: The number of leading zeros is returned.

Examples:

import std.math.leadingZeros

main() {
    let x: UInt16 = 512
    let leadingZeros = leadingZeros(x)
    println(leadingZeros)
}

Results:

6

func leadingZeros(UInt32)

public func leadingZeros(x: UInt32): Int64

Description: Obtains the number of consecutive 0s starting from the most significant bit in the binary expression of a 32-bit unsigned integer. If the most significant bit is not 0, the value 0 is returned.

Parameters:

  • x: UInt32: integer of which the number of leading zeros is to be obtained

Returns:

  • Int64: The number of leading zeros is returned.

Examples:

import std.math.leadingZeros

main() {
    let x: UInt32 = 512
    let leadingZeros = leadingZeros(x)
    println(leadingZeros)
}

Results:

22

func leadingZeros(UInt64)

public func leadingZeros(x: UInt64): Int64

Description: Obtains the number of consecutive 0s starting from the most significant bit in the binary expression of a 64-bit unsigned integer. If the most significant bit is not 0, the value 0 is returned.

Parameters:

  • x: UInt64: integer of which the number of leading zeros is to be obtained

Returns:

  • Int64: The number of leading zeros is returned.

Examples:

import std.math.leadingZeros

main() {
    let x: UInt64 = 512
    let leadingZeros = leadingZeros(x)
    println(leadingZeros)
}

Results:

54

func leadingZeros(UInt8)

public func leadingZeros(x: UInt8): Int64

Description: Obtains the number of consecutive 0s starting from the most significant bit in the binary expression of an 8-bit unsigned integer. If the most significant bit is not 0, the value 0 is returned.

Parameters:

  • x: UInt8: integer of which the number of leading zeros is to be obtained

Returns:

  • Int64: The number of leading zeros is returned.

Examples:

import std.math.leadingZeros

main() {
    let x: UInt8 = 64
    let leadingZeros = leadingZeros(x)
    println(leadingZeros)
}

Results:

1

func log(Float16)

public func log(x: Float16): Float16

Description: Obtains the logarithm of x with base e.

Parameters:

Returns:

  • Float16: The logarithm of x with base e is returned.

NOTE

Special scenarios of return values are as follows:

  • If the input x is less than 0 or is NaN, NaN is returned.
  • If the input x is 0, -Inf is returned.
  • If the input x is Inf, Inf is returned.

Examples:

import std.math.log

main() {
    let x: Float16 = 2.718282
    let log1 = log(x)
    let log2 = log(-x)
    let log3 = log(0.0)

    println(log1)
    println(log2)
    println(log3)

    let log4 = -log3
    println(log4)
}

Results:

1.000000
nan
-inf
inf

func log(Float32)

public func log(x: Float32): Float32

Description: Obtains the logarithm of x with base e.

Parameters:

Returns:

  • Float32: The logarithm of x with base e is returned.

NOTE

Special scenarios of return values are as follows:

  • If the input x is less than 0 or is NaN, NaN is returned.
  • If the input x is 0, -Inf is returned.
  • If the input x is Inf, Inf is returned.

Examples:

import std.math.log

main() {
    let x: Float32 = 2.718282
    let log = log(x)
    println(log)
}

Results:

1.000000

func log(Float64)

public func log(x: Float64): Float64

Description: Obtains the logarithm of x with base e.

Parameters:

Returns:

  • Float64: The logarithm of x with base e is returned.

NOTE

Special scenarios of return values are as follows:

  • If the input x is less than 0 or is NaN, NaN is returned.
  • If the input x is 0, -Inf is returned.
  • If the input x is Inf, Inf is returned.

Examples:

import std.math.log

main() {
    let x: Float64 = 2.718282
    let log = log(x)
    println(log)
}

Results:

1.000000

func log10(Float16)

public func log10(x: Float16): Float16

Description: Obtains the logarithm of x with base 10.

Parameters:

Returns:

  • Float16: The logarithm of x with base 10 is returned.

NOTE

Special scenarios of return values are as follows:

  • If the input x is less than 0 or is NaN, NaN is returned.
  • If the input x is 0, -Inf is returned.
  • If the input x is Inf, Inf is returned.

Examples:

import std.math.log10

main() {
    let x: Float16 = 1000.0
    let log10 = log10(x)
    println(log10)
}

Results:

3.000000

func log10(Float32)

public func log10(x: Float32): Float32

Description: Obtains the logarithm of x with base 10.

Parameters:

Returns:

  • Float32: The logarithm of x with base 10 is returned.

NOTE

Special scenarios of return values are as follows:

  • If the input x is less than 0 or is NaN, NaN is returned.
  • If the input x is 0, -Inf is returned.
  • If the input x is Inf, Inf is returned.

Examples:

import std.math.log10

main() {
    let x: Float32 = 1000.0
    let log10 = log10(x)
    println(log10)
}

Results:

3.000000

func log10(Float64)

public func log10(x: Float64): Float64

Description: Obtains the logarithm of x with base 10.

Parameters:

Returns:

  • Float64: The logarithm of x with base 10 is returned.

NOTE

Special scenarios of return values are as follows:

  • If the input x is less than 0 or is NaN, NaN is returned.
  • If the input x is 0, -Inf is returned.
  • If the input x is Inf, Inf is returned.

Examples:

import std.math.log10

main() {
    let x: Float64 = 1000.0
    let log10 = log10(x)
    println(log10)
}

Results:

3.000000

func log2(Float16)

public func log2(x: Float16): Float16

Description: Obtains the logarithm of x with base 2.

Parameters:

Returns:

  • Float16: The logarithm of x with base 2 is returned.

NOTE

Special scenarios of return values are as follows:

  • If the input x is less than 0 or is NaN, NaN is returned.
  • If the input x is 0, -Inf is returned.
  • If the input x is Inf, Inf is returned.

Examples:

import std.math.log2

main() {
    let x: Float16 = 1024.0
    let log2 = log2(x)
    println(log2)
}

Results:

10.000000

func log2(Float32)

public func log2(x: Float32): Float32

Description: Obtains the logarithm of x with base 2.

Parameters:

Returns:

  • Float32: The logarithm of x with base 2 is returned.

NOTE

Special scenarios of return values are as follows:

  • If the input x is less than 0 or is NaN, NaN is returned.
  • If the input x is 0, -Inf is returned.
  • If the input x is Inf, Inf is returned.

Examples:

import std.math.log2

main() {
    let x: Float32 = 1024.0
    let log2 = log2(x)
    println(log2)
}

Results:

10.000000

func log2(Float64)

public func log2(x: Float64): Float64

Description: Obtains the logarithm of x with base 2.

Parameters:

Returns:

  • Float64: The logarithm of x with base 2 is returned.

NOTE

Special scenarios of return values are as follows:

  • If the input x is less than 0 or is NaN, NaN is returned.
  • If the input x is 0, -Inf is returned.
  • If the input x is Inf, Inf is returned.

Examples:

import std.math.log2

main() {
    let x: Float64 = 1024.0
    let log2 = log2(x)
    println(log2)
}

Results:

10.000000

func logBase(Float16, Float16)

public func logBase(x: Float16, base: Float16): Float16

Description: Obtains the logarithm of x with base base.

Parameters:

  • x: Float16: antilogarithm, which must be greater than 0
  • base: Float16: base, which must be greater than 0 and cannot be 1

Returns:

  • Float16: The logarithm of x with base base is returned.

Throws:

Examples:

import std.math.logBase

main() {
    let x: Float16 = 512.0
    let base: Float16 = 2.0
    let logBase = logBase(x, base)
    println(logBase)
}

Results:

9.000000

Examples of Throws:

import std.math.logBase

main() {
    let x: Float16 = 512.0
    let base: Float16 = -2.0

    // Example 1: The base is negative.
    try {
        let logBase1 = logBase(x, base)
        println(logBase1)
    } catch (e: IllegalArgumentException) {
        println("Exception 1: The base is negative.")
    }

    // Example 2: The argument is negative.
    try {
        let logBase2 = logBase(-x, base)
        println(logBase2)
    } catch (e: IllegalArgumentException) {
        println("Exception 2: The argument is negative.")
    }

    // Example 3: The base is 1.
    try {
        let logBase3 = logBase(x, 1.0)
        println(logBase3)
    } catch (e: IllegalArgumentException) {
        println("Exception 3: The base is 1.")
    }
}

Results:

Exception 1: The base is negative.
Exception 2: The argument is negative.
Exception 3: The base is 1.

func logBase(Float32, Float32)

public func logBase(x: Float32, base: Float32): Float32

Description: Obtains the logarithm of x with base base.

Parameters:

  • x: Float32: antilogarithm, which must be greater than 0
  • base: Float32: base, which must be greater than 0 and cannot be 1

Returns:

  • Float32: The logarithm of x with base base is returned.

Throws:

Examples:

import std.math.logBase

main() {
    let x: Float32 = 1024.0
    let base: Float32 = 2.0
    let logBase = logBase(x, base)
    println(logBase)
}

Results:

10.000000

func logBase(Float64, Float64)

public func logBase(x: Float64, base: Float64): Float64

Description: Obtains the logarithm of x with base base.

Parameters:

  • x: Float64: antilogarithm, which must be greater than 0
  • base: Float64: base, which must be greater than 0 and cannot be 1

Returns:

  • Float64: The logarithm of x with base base is returned.

Throws:

Examples:

import std.math.logBase

main() {
    let x: Float64 = 1024.0
    let base: Float64 = 2.0
    let logBase = logBase(x, base)
    println(logBase)
}

Results:

10.000000

func pow(Float32, Float32)

public func pow(base: Float32, exponent: Float32): Float32

Description: Obtains the floating-point number base raised to the power of exponent.

Parameters:

Returns:

  • Float32: The floating-point number base raised to the power of exponent is returned. If the value does not exist, nan is returned.

Examples:

import std.math.pow

main() {
    let base: Float32 = -1.0
    let exponent: Float32 = 0.5
    let pow = pow(base, exponent)
    println(pow)
}

Results:

nan

func pow(Float32, Int32)

public func pow(base: Float32, exponent: Int32): Float32

Description: Obtains the floating-point number base raised to the power of exponent.

Parameters:

Returns:

  • Float32: The floating-point number base raised to the power of exponent is returned.

Examples:

import std.math.pow

main() {
    let base: Float32 = -1.0
    let exponent: Int32 = 2
    let pow = pow(base, exponent)
    println(pow)
}

Results:

1.000000

func pow(Float64, Float64)

public func pow(base: Float64, exponent: Float64): Float64

Description: Obtains the floating-point number base raised to the power of exponent.

Parameters:

Returns:

  • Float64: The floating-point number base raised to the power of exponent is returned. If the value does not exist, nan is returned.

Examples:

import std.math.pow

main() {
    let base: Float64 = -1.0
    let exponent: Float64 = 0.5
    let pow = pow(base, exponent)
    println(pow)
}

Results:

nan

func pow(Float64, Int64)

public func pow(base: Float64, exponent: Int64): Float64

Description: Obtains the floating-point number base raised to the power of exponent.

Parameters:

Returns:

  • Float64: The floating-point number base raised to the power of exponent is returned.

Examples:

import std.math.pow

main() {
    let base: Float64 = -1.0
    let exponent: Int64 = 2
    let pow = pow(base, exponent)
    println(pow)
}

Results:

1.000000

func reverse(UInt16)

public func reverse(x: UInt16): UInt16

Description: Obtains the number after bitwise inversion of an unsigned integer.

Parameters:

  • x: UInt16: unsigned integer to be inversed

Returns:

  • UInt16: The unsigned number after inversion is returned.

Examples:

import std.math.reverse

main() {
    let n: UInt16 = 0x8000
    let reverse = reverse(n)
    println(reverse)
}

Results:

1

func reverse(UInt32)

public func reverse(x: UInt32): UInt32

Description: Obtains the number after bitwise inversion of an unsigned integer.

Parameters:

  • x: UInt32: unsigned integer to be inversed

Returns:

  • UInt32: The unsigned number after inversion is returned.

Examples:

import std.math.reverse

main() {
    let n: UInt32 = 0x8000_0000
    let reverse = reverse(n)
    println(reverse)
}

Results:

1

func reverse(UInt64)

public func reverse(x: UInt64): UInt64

Description: Obtains the number after bitwise inversion of an unsigned integer.

Parameters:

  • x: UInt64: unsigned integer to be inversed

Returns:

  • UInt64: The unsigned number after inversion is returned.

Examples:

import std.math.reverse

main() {
    let n: UInt64 = 0x8000_0000_0000_0000
    let reverse = reverse(n)
    println(reverse)
}

Results:

1

func reverse(UInt8)

public func reverse(x: UInt8): UInt8

Description: Obtains the number after bitwise inversion of an unsigned integer.

Parameters:

  • x: UInt8: unsigned integer to be inversed

Returns:

  • UInt8: The unsigned number after inversion is returned.

Examples:

import std.math.reverse

main() {
    let n: UInt8 = 0x80
    let reverse = reverse(n)
    println(reverse)
}

Results:

1

func rotate(Int16, Int8)

public func rotate(num: Int16, d: Int8): Int16

Description: Obtains the result of bitwise rotation of an integer.

Parameters:

  • num: Int16: integer input
  • d: Int8: number of bits for rotation; rules: negative numbers shifted rightwards and positive numbers shifted leftwards

Returns:

  • Int16: The integer after rotation is returned.

Examples:

import std.math.rotate

main() {
    let n: Int16 = 1
    let rotate = rotate(n, 2)
    println(rotate)
}

Results:

4

func rotate(Int32, Int8)

public func rotate(num: Int32, d: Int8): Int32

Description: Obtains the result of bitwise rotation of an integer.

Parameters:

  • num: Int32: integer input
  • d: Int8: number of bits for rotation; rules: negative numbers shifted rightwards and positive numbers shifted leftwards

Returns:

  • Int32: The integer after rotation is returned.

Examples:

import std.math.rotate

main() {
    let n: Int32 = 1
    let rotate = rotate(n, 2)
    println(rotate)
}

Results:

4

func rotate(Int64, Int8)

public func rotate(num: Int64, d: Int8): Int64

Description: Obtains the result of bitwise rotation of an integer.

Parameters:

  • num: Int64: integer input
  • d: Int8: number of bits for rotation; rules: negative numbers shifted rightwards and positive numbers shifted leftwards

Returns:

  • Int64: The integer after rotation is returned.

Examples:

import std.math.rotate

main() {
    let n: Int64 = 1
    let rotate = rotate(n, 2)
    println(rotate)
}

Results:

4

func rotate(Int8, Int8)

public func rotate(num: Int8, d: Int8): Int8

Description: Obtains the result of bitwise rotation of an integer.

Parameters:

  • num: Int8: integer input
  • d: Int8: number of bits for rotation; rules: negative numbers shifted rightwards and positive numbers shifted leftwards

Returns:

  • Int8: The integer after rotation is returned.

Examples:

import std.math.rotate

main() {
    let n: Int8 = 1
    let rotate = rotate(n, 2)
    println(rotate)
}

Results:

4

func rotate(UInt16, Int8)

public func rotate(num: UInt16, d: Int8): UInt16

Description: Obtains the result of bitwise rotation of an integer.

Parameters:

  • num: UInt16: integer input
  • d: Int8: number of bits for rotation; rules: negative numbers shifted rightwards and positive numbers shifted leftwards

Returns:

  • UInt16: The integer after rotation is returned.

Examples:

import std.math.rotate

main() {
    let n: UInt16 = 1
    let rotate = rotate(n, 2)
    println(rotate)
}

Results:

4

func rotate(UInt32, Int8)

public func rotate(num: UInt32, d: Int8): UInt32

Description: Obtains the result of bitwise rotation of an integer.

Parameters:

  • num: UInt32: integer input
  • d: Int8: number of bits for rotation; rules: negative numbers shifted rightwards and positive numbers shifted leftwards

Returns:

  • UInt32: The integer after rotation is returned.

Examples:

import std.math.rotate

main() {
    let n: UInt32 = 1
    let rotate = rotate(n, 2)
    println(rotate)
}

Results:

4

func rotate(UInt64, Int8)

public func rotate(num: UInt64, d: Int8): UInt64

Description: Obtains the result of bitwise rotation of an integer.

Parameters:

  • num: UInt64: integer input
  • d: Int8: number of bits for rotation; rules: negative numbers shifted rightwards and positive numbers shifted leftwards

Returns:

  • UInt64: The integer after rotation is returned.

Examples:

import std.math.rotate

main() {
    let n: UInt64 = 1
    let rotate = rotate(n, 2)
    println(rotate)
}

Results:

4

func rotate(UInt8, Int8)

public func rotate(num: UInt8, d: Int8): UInt8

Description: Obtains the result of bitwise rotation of an integer.

Parameters:

  • num: UInt8: integer input
  • d: Int8: number of bits for rotation; rules: negative numbers shifted rightwards and positive numbers shifted leftwards

Returns:

  • UInt8: The integer after rotation is returned.

Examples:

import std.math.rotate

main() {
    let n: UInt8 = 1
    let rotate = rotate(n, 2)
    println(rotate)
}

Results:

4

func round(Float16)

public func round(x: Float16): Float16

Description: Obtains the rounded-off value of a floating-point number through calculation based on the round-off rule in IEEE-754. A floating-point number having two nearest integers is rounded to the even number.

Parameters:

  • x: Float16: floating-point number whose rounded-off value is to be obtained through calculation

Returns:

  • Float16: The rounded-off value of the floating-point number is returned. If the floating-point number has two nearest integers, the even number is returned.

Examples:

import std.math.round

main() {
    let n: Float16 = 1.5
    let round = round(n)
    println(round)
}

Results:

2.000000

func round(Float32)

public func round(x: Float32): Float32

Description: Obtains the rounded-off value of a floating-point number through calculation based on the round-off rule in IEEE-754. A floating-point number having two nearest integers is rounded to the even number.

Parameters:

  • x: Float32: floating-point number whose rounded-off value is to be obtained through calculation

Returns:

  • Float32: The rounded-off value of the floating-point number is returned. If the floating-point number has two nearest integers, the even number is returned.

Examples:

import std.math.round

main() {
    let n: Float32 = 1.5
    let round = round(n)
    println(round)
}

Results:

2.000000

func round(Float64)

public func round(x: Float64): Float64

Description: Obtains the rounded-off value of a floating-point number through calculation based on the round-off rule in IEEE-754. A floating-point number having two nearest integers is rounded to the even number.

Parameters:

  • x: Float64: floating-point number whose rounded-off value is to be obtained through calculation

Returns:

  • Float64: The rounded-off value of the floating-point number is returned. If the floating-point number has two nearest integers, the even number is returned.

Examples:

import std.math.round

main() {
    let n: Float64 = 1.5
    let round = round(n)
    println(round)
}

Results:

2.000000

func sin(Float16)

public func sin(x: Float16): Float16

Description: Obtains the sine function value of a half-precision floating-point number through calculation.

Parameters:

  • x: Float16: half-precision floating-point number input, in radians

Returns:

  • Float16: The sine function value of the input parameter is returned.

Examples:

import std.math.sin

main() {
    let n: Float16 = 3.1415926/2.0
    let sin = sin(n)
    println(sin)
}

Results:

1.000000

func sin(Float32)

public func sin(x: Float32): Float32

Description: Obtains the sine function value of a single-precision floating-point number through calculation.

Parameters:

  • x: Float32: single-precision floating-point number input, in radians

Returns:

  • Float32: The sine function value of the input parameter is returned.

Examples:

import std.math.sin

main() {
    let n: Float32 = 3.1415926/2.0
    let sin = sin(n)
    println(sin)
}

Results:

1.000000

func sin(Float64)

public func sin(x: Float64): Float64

Description: Obtains the sine function value of a double-precision floating-point number through calculation.

Parameters:

  • x: Float64: double-precision floating-point number input, in radians

Returns:

  • Float64: The sine function value of the input parameter is returned.

Examples:

import std.math.sin

main() {
    let n: Float64 = 3.1415926/2.0
    let sin = sin(n)
    println(sin)
}

Results:

1.000000

func sinh(Float16)

public func sinh(x: Float16): Float16

Description: Obtains the hyperbolic sine function value of a half-precision floating-point number through calculation.

Parameters:

  • x: Float16: half-precision floating-point number input

Returns:

  • Float16: The hyperbolic sine function value of the input parameter is returned.

Examples:

import std.math.sinh

main() {
    let n: Float16 = 0.0
    let sinh = sinh(n)
    println(sinh)
}

Results:

0.000000

func sinh(Float32)

public func sinh(x: Float32): Float32

Description: Obtains the hyperbolic sine function value of a single-precision floating-point number through calculation.

Parameters:

  • x: Float32: single-precision floating-point number input

Returns:

  • Float32: The hyperbolic sine function value of the input parameter is returned.

Examples:

import std.math.sinh

main() {
    let n: Float32 = 0.0
    let sinh = sinh(n)
    println(sinh)
}

Results:

0.000000

func sinh(Float64)

public func sinh(x: Float64): Float64

Description: Obtains the hyperbolic sine function value of a double-precision floating-point number through calculation.

Parameters:

  • x: Float64: double-precision floating-point number input

Returns:

  • Float64: The hyperbolic sine function value of the input parameter is returned.

Examples:

import std.math.sinh

main() {
    let n: Float64 = 0.0
    let sinh = sinh(n)
    println(sinh)
}

Results:

0.000000

func sqrt(Float16)

public func sqrt(x: Float16): Float16

Description: Obtains the arithmetic square root of a floating-point number.

Parameters:

  • x: Float16: floating-point number whose arithmetic square root is to be obtained through calculation. The value of x must be greater than or equal to 0.

Returns:

  • Float16: The arithmetic square root of the input floating-point number is returned.

Throws:

Examples:

import std.math.sqrt

main() {
    let n: Float16 = 16.0
    let sqrt = sqrt(n)
    println(sqrt)
}

Results:

4.000000

func sqrt(Float32)

public func sqrt(x: Float32): Float32

Description: Obtains the arithmetic square root of a floating-point number.

Parameters:

  • x: Float32: floating-point number whose arithmetic square root is to be obtained through calculation. The value of x must be greater than or equal to 0.

Returns:

  • Float32: The arithmetic square root of the input floating-point number is returned.

Throws:

Examples:

import std.math.sqrt

main() {
    let n: Float32 = 16.0
    let sqrt = sqrt(n)
    println(sqrt)
}

Results:

4.000000

func sqrt(Float64)

public func sqrt(x: Float64): Float64

Description: Obtains the arithmetic square root of a floating-point number.

Parameters:

  • x: Float64: floating-point number whose arithmetic square root is to be obtained through calculation. The value of x must be greater than or equal to 0.

Returns:

  • Float64: The arithmetic square root of the input floating-point number is returned.

Throws:

Examples:

import std.math.sqrt

main() {
    let n: Float64 = 16.0
    let sqrt = sqrt(n)
    println(sqrt)
}

Results:

4.000000

func tan(Float16)

public func tan(x: Float16): Float16

Description: Obtains the tangent function value of a half-precision floating-point number through calculation.

Parameters:

  • x: Float16: half-precision floating-point number input, in radians

Returns:

  • Float16: The tangent function value of the input parameter is returned.

Examples:

import std.math.tan

main() {
    let n: Float16 = 0.0
    let tan = tan(n)
    println(tan)
}

Results:

0.000000

func tan(Float32)

public func tan(x: Float32): Float32

Description: Obtains the tangent function value of a single-precision floating-point number through calculation.

Parameters:

  • x: Float32: single-precision floating-point number input, in radians

Returns:

  • Float32: The tangent function value of the input parameter is returned.

Examples:

import std.math.tan

main() {
    let n: Float32 = 0.0
    let tan = tan(n)
    println(tan)
}

Results:

0.000000

func tan(Float64)

public func tan(x: Float64): Float64

Description: Obtains the tangent function value of a double-precision floating-point number through calculation.

Parameters:

  • x: Float64: double-precision floating-point number input, in radians

Returns:

  • Float64: The tangent function value of the input parameter is returned.

Examples:

import std.math.tan

main() {
    let n: Float64 = 0.0
    let tan = tan(n)
    println(tan)
}

Results:

0.000000

func tanh(Float16)

public func tanh(x: Float16): Float16

Description: Obtains the hyperbolic tangent function value of a half-precision floating-point number through calculation.

Parameters:

  • x: Float16: half-precision floating-point number input

Returns:

  • Float16: The hyperbolic tangent function value of the input parameter is returned.

Examples:

import std.math.tanh

main() {
    let n: Float16 = 0.0
    let tanh = tanh(n)
    println(tanh)
}

Results:

0.000000

func tanh(Float32)

public func tanh(x: Float32): Float32

Description: Obtains the hyperbolic tangent function value of a single-precision floating-point number through calculation.

Parameters:

  • x: Float32: single-precision floating-point number input

Returns:

  • Float32: The hyperbolic tangent function value of the input parameter is returned.

Examples:

import std.math.tanh

main() {
    let n: Float32 = 0.0
    let tanh = tanh(n)
    println(tanh)
}

Results:

0.000000

func tanh(Float64)

public func tanh(x: Float64): Float64

Description: Obtains the hyperbolic tangent function value of a double-precision floating-point number through calculation.

Parameters:

  • x: Float64: double-precision floating-point number input

Returns:

  • Float64: The hyperbolic tangent function value of the input parameter is returned.

Examples:

import std.math.tanh

main() {
    let n: Float64 = 0.0
    let tanh = tanh(n)
    println(tanh)
}

Results:

0.000000

func trailingZeros(Int16)

public func trailingZeros(x: Int16): Int64

Description: Obtains the number of consecutive 0s starting from the least significant bit in the binary expression of a 16-bit signed integer. If the least significant bit is not 0, the value 0 is returned.

Parameters:

  • x: Int16: integer of which the number of trailing zeros is to be obtained

Returns:

  • Int64: number of trailing zeros

Examples:

import std.math.trailingZeros

main() {
    let x: Int16 = 512
    let trailingZeros = trailingZeros(x)
    println(trailingZeros)
}

Results:

9

func trailingZeros(Int32)

public func trailingZeros(x: Int32): Int64

Description: Obtains the number of consecutive 0s starting from the least significant bit in the binary expression of a 32-bit signed integer. If the least significant bit is not 0, the value 0 is returned.

Parameters:

  • x: Int32: integer of which the number of trailing zeros is to be obtained

Returns:

  • Int64: number of trailing zeros

Examples:

import std.math.trailingZeros

main() {
    let x: Int32 = 512
    let trailingZeros = trailingZeros(x)
    println(trailingZeros)
}

Results:

9

func trailingZeros(Int64)

public func trailingZeros(x: Int64): Int64

Description: Obtains the number of consecutive 0s starting from the least significant bit in the binary expression of a 64-bit signed integer. If the least significant bit is not 0, the value 0 is returned.

Parameters:

  • x: Int64: integer of which the number of trailing zeros is to be obtained

Returns:

  • Int64: number of trailing zeros

Examples:

import std.math.trailingZeros

main() {
    let x: Int64 = 512
    let trailingZeros = trailingZeros(x)
    println(trailingZeros)
}

Results:

9

func trailingZeros(Int8)

public func trailingZeros(x: Int8): Int64

Description: Obtains the number of consecutive 0s starting from the least significant bit in the binary expression of a 16-bit signed integer. If the least significant bit is not 0, the value 0 is returned.

Parameters:

  • x: Int8: integer of which the number of trailing zeros is to be obtained

Returns:

  • Int64: number of trailing zeros

Examples:

import std.math.trailingZeros

main() {
    let x: Int8 = 64
    let trailingZeros = trailingZeros(x)
    println(trailingZeros)
}

Results:

6

func trailingZeros(UInt16)

public func trailingZeros(x: UInt16): Int64

Description: Obtains the number of consecutive 0s starting from the least significant bit in the binary expression of a 16-bit unsigned integer. If the least significant bit is not 0, the value 0 is returned.

Parameters:

  • x: UInt16: integer of which the number of trailing zeros is to be obtained

Returns:

  • Int64: number of trailing zeros

Examples:

import std.math.trailingZeros

main() {
    let x: UInt16 = 512
    let trailingZeros = trailingZeros(x)
    println(trailingZeros)
}

Results:

9

func trailingZeros(UInt32)

public func trailingZeros(x: UInt32): Int64

Description: Obtains the number of consecutive 0s starting from the least significant bit in the binary expression of a 32-bit unsigned integer. If the least significant bit is not 0, the value 0 is returned.

Parameters:

  • x: UInt32: integer of which the number of trailing zeros is to be obtained

Returns:

  • Int64: number of trailing zeros

Examples:

import std.math.trailingZeros

main() {
    let x: UInt32 = 512
    let trailingZeros = trailingZeros(x)
    println(trailingZeros)
}

Results:

9

func trailingZeros(UInt64)

public func trailingZeros(x: UInt64): Int64

Description: Obtains the number of consecutive 0s starting from the least significant bit in the binary expression of a 64-bit unsigned integer. If the least significant bit is not 0, the value 0 is returned.

Parameters:

  • x: UInt64: integer of which the number of trailing zeros is to be obtained

Returns:

  • Int64: number of trailing zeros

Examples:

import std.math.trailingZeros

main() {
    let x: UInt64 = 512
    let trailingZeros = trailingZeros(x)
    println(trailingZeros)
}

Results:

9

func trailingZeros(UInt8)

public func trailingZeros(x: UInt8): Int64

Description: Obtains the number of consecutive 0s starting from the least significant bit in the binary expression of an 8-bit unsigned integer. If the least significant bit is not 0, the value 0 is returned.

Parameters:

  • x: UInt8: integer of which the number of trailing zeros is to be obtained

Returns:

  • Int64: number of trailing zeros

Examples:

import std.math.trailingZeros

main() {
    let x: UInt8 = 64
    let trailingZeros = trailingZeros(x)
    println(trailingZeros)
}

Results:

6

func trunc(Float16)

public func trunc(x: Float16): Float16

Description: Obtains the value after truncation of a floating-point number.

Parameters:

  • x: Float16: floating-point number to be truncated

Returns:

  • Float16: The value after truncation of the input floating-point number is returned.

Examples:

import std.math.trunc

main() {
    let x: Float16 = 64.555566
    let trunc = trunc(x)
    println(trunc)
}

Results:

64.000000

func trunc(Float32)

public func trunc(x: Float32): Float32

Description: Obtains the value after truncation of a floating-point number.

Parameters:

  • x: Float32: floating-point number to be truncated

Returns:

  • Float32: The value after truncation of the input floating-point number is returned.

Examples:

import std.math.trunc

main() {
    let x: Float32 = 64.555566
    let trunc = trunc(x)
    println(trunc)
}

Results:

64.000000

func trunc(Float64)

public func trunc(x: Float64): Float64

Description: Obtains the value after truncation of a floating-point number.

Parameters:

  • x: Float64: floating-point number to be truncated

Returns:

  • Float64: The value after truncation of the input floating-point number is returned.

Examples:

import std.math.trunc

main() {
    let x: Float64 = 64.555566
    let trunc = trunc(x)
    println(trunc)
}

Results:

64.000000