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.

Example:

import std.math.abs

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

Running result:

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.

Example:

import std.math.abs

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

Running result:

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.

Example:

import std.math.abs

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

Running result:

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.

Example:

import std.math.abs

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

Running result:

23

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.

Example:

import std.math.abs

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

Running result:

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.

Example:

import std.math.abs

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

Running result:

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.

Example:

import std.math.abs

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

Running result:

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.

Example:

import std.math.acos

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

Running result:

0.000000

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.

Example:

import std.math.acos

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

Running result:

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.

Example:

import std.math.acos

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

Running result:

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:

Example:

import std.math.acosh

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

Running result:

0.000000

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:

Example:

import std.math.acosh

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

Running result:

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:

Example:

import std.math.acosh

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

Running result:

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.

Example:

import std.math.asin

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

Running result:

0.000000

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.

Example:

import std.math.asin

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

Running result:

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.

Example:

import std.math.asin

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

Running result:

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.

Example:

import std.math.asinh

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

Running result:

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.

Example:

import std.math.asinh

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

Running result:

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.

Example:

import std.math.asinh

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

Running result:

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.

Example:

import std.math.atan

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

Running result:

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.

Example:

import std.math.atan

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

Running result:

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.

Example:

import std.math.atan

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

Running result:

0.000000

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.

Example:

import std.math.atanh

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

Running result:

0.000000

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.

Example:

import std.math.atanh

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

Running result:

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.

Example:

import std.math.atanh

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

Running result:

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.

Example:

import std.math.cbrt

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

Running result:

-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.

Example:

import std.math.cbrt

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

Running result:

-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.

Example:

import std.math.cbrt

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

Running result:

-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.

Example:

import std.math.ceil

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

Running result:

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.

Example:

import std.math.ceil

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

Running result:

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.

Example:

import std.math.ceil

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

Running result:

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.

Example:

import std.math.checkedAbs

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

Running result:

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.

Example:

import std.math.checkedAbs

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

Running result:

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.

Example:

import std.math.checkedAbs

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

Running result:

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.

Example:

import std.math.checkedAbs

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

Running result:

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.

Example:

import std.math.clamp

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

Running result:

-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.

Example:

import std.math.clamp

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

Running result:

-23.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.

Example:

import std.math.clamp

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

Running result:

-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.

Example:

import std.math.cos

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

Running result:

-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.

Example:

import std.math.cos

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

Running result:

-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.

Example:

import std.math.cos

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

Running result:

-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.

Example:

import std.math.cosh

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

Running result:

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.

Example:

import std.math.cosh

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

Running result:

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.

Example:

import std.math.cosh

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

Running result:

1.000000

func countOne(Int16)

public func countOne(x: Int16): Int8

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

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.

Example:

import std.math.countOne

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

Running result:

4

func countOne(Int32)

public func countOne(x: Int32): Int8

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

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.

Example:

import std.math.countOne

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

Running result:

4

func countOne(Int64)

public func countOne(x: Int64): Int8

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

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.

Example:

import std.math.countOne

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

Running result:

4

func countOne(Int8)

public func countOne(x: Int8): Int8

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

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.

Example:

import std.math.countOne

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

Running result:

4

func countOne(UInt16)

public func countOne(x: UInt16): Int8

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:

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

Example:

import std.math.countOne

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

Running result:

4

func countOne(UInt32)

public func countOne(x: UInt32): Int8

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:

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

Example:

import std.math.countOne

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

Running result:

4

func countOne(UInt64)

public func countOne(x: UInt64): Int8

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:

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

Example:

import std.math.countOne

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

Running result:

4

func countOne(UInt8)

public func countOne(x: UInt8): Int8

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:

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

Example:

import std.math.countOne

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

Running result:

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.

Example:

import std.math.erf

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

Running result:

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.

Example:

import std.math.erf

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

Running result:

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.

Example:

import std.math.erf

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

Running result:

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.

Example:

import std.math.exp

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

Running result:

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.

Example:

import std.math.exp

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

Running result:

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.

Example:

import std.math.exp

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

Running result:

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.

Example:

import std.math.exp2

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

Running result:

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.

Example:

import std.math.exp2

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

Running result:

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.

Example:

import std.math.exp2

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

Running result:

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.

Example:

import std.math.floor

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

Running result:

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.

Example:

import std.math.floor

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

Running result:

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.

Example:

import std.math.floor

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

Running result:

10.000000

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.

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.

Example:

import std.math.gamma

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

Running result:

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.

Example:

import std.math.gamma

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

Running result:

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.

Example:

import std.math.gamma

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

Running result:

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.

Example:

import std.math.gcd

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

Running result:

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.

Example:

import std.math.gcd

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

Running result:

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.

Example:

import std.math.gcd

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

Running result:

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.

Example:

import std.math.gcd

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

Running result:

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.

Example:

import std.math.gcd

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

Running result:

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.

Example:

import std.math.gcd

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

Running result:

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.

Example:

import std.math.gcd

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

Running result:

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.

Example:

import std.math.gcd

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

Running result:

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.

Example:

import std.math.lcm

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

Running result:

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.

Example:

import std.math.lcm

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

Running result:

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.

Example:

import std.math.lcm

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

Running result:

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.

Example:

import std.math.lcm

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

Running result:

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.

Example:

import std.math.lcm

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

Running result:

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.

Example:

import std.math.lcm

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

Running result:

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.

Example:

import std.math.lcm

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

Running result:

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.

Example:

import std.math.lcm

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

Running result:

45

func leadingZeros(Int16)

public func leadingZeros(x: Int16): Int8

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:

  • Int8: The number of leading zeros is returned.

Example:

import std.math.leadingZeros

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

Running result:

6

func leadingZeros(Int32)

public func leadingZeros(x: Int32): Int8

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:

  • Int8: The number of leading zeros is returned.

Example:

import std.math.leadingZeros

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

Running result:

22

func leadingZeros(Int64)

public func leadingZeros(x: Int64): Int8

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:

  • Int8: The number of leading zeros is returned.

Example:

import std.math.leadingZeros

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

Running result:

54

func leadingZeros(Int8)

public func leadingZeros(x: Int8): Int8

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:

  • Int8: The number of leading zeros is returned.

Example:

import std.math.leadingZeros

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

Running result:

5

func leadingZeros(UInt16)

public func leadingZeros(x: UInt16): Int8

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:

  • Int8: The number of leading zeros is returned.

Example:

import std.math.leadingZeros

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

Running result:

6

func leadingZeros(UInt32)

public func leadingZeros(x: UInt32): Int8

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:

  • Int8: The number of leading zeros is returned.

Example:

import std.math.leadingZeros

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

Running result:

22

func leadingZeros(UInt64)

public func leadingZeros(x: UInt64): Int8

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:

  • Int8: The number of leading zeros is returned.

Example:

import std.math.leadingZeros

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

Running result:

54

func leadingZeros(UInt8)

public func leadingZeros(x: UInt8): Int8

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:

  • Int8: The number of leading zeros is returned.

Example:

import std.math.leadingZeros

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

Running result:

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.

Example:

import std.math.log

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

Running result:

1.000000

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.

Example:

import std.math.log

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

Running result:

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.

Example:

import std.math.log

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

Running result:

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.

Example:

import std.math.log10

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

Running result:

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.

Example:

import std.math.log10

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

Running result:

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.

Example:

import std.math.log10

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

Running result:

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.

Example:

import std.math.log2

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

Running result:

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.

Example:

import std.math.log2

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

Running result:

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.

Example:

import std.math.log2

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

Running result:

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:

Example:

import std.math.logBase

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

Running result:

9.000000

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:

Example:

import std.math.logBase

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

Running result:

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:

Example:

import std.math.logBase

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

Running result:

10.000000

func max(Float16, Float16)

public func max(a: Float16, b: Float16): Float16

Description: Obtains the larger value between two numbers. If any input parameter is NaN, NaN is returned.

Parameters:

  • a: Float16: one number to be compared
  • b: Float16: the other number to be compared

Returns:

  • Float16: The larger value between the two numbers is returned. If any input parameter is NaN, NaN is returned.

Example:

import std.math.max

main() {
    let a: Float16 = 1.0
    let b: Float16 = 2.0
    let max = max(a, b)
    println(max)
}

Running result:

2.000000

func max(Float32, Float32)

public func max(a: Float32, b: Float32): Float32

Description: Obtains the larger value between two numbers. If any input parameter is NaN, NaN is returned.

Parameters:

  • a: Float32: one number to be compared
  • b: Float32: the other number to be compared

Returns:

  • Float32: The larger value between the two numbers is returned. If any input parameter is NaN, NaN is returned.

Example:

import std.math.max

main() {
    let a: Float32 = 1.0
    let b: Float32 = 2.0
    let max = max(a, b)
    println(max)
}

Running result:

2.000000

func max(Float64, Float64)

public func max(a: Float64, b: Float64): Float64

Description: Obtains the larger value between two numbers. If any input parameter is NaN, NaN is returned.

Parameters:

  • a: Float64: one number to be compared
  • b: Float64: the other number to be compared

Returns:

  • Float64: The larger value between the two numbers is returned. If any input parameter is NaN, NaN is returned.

Example:

import std.math.max

main() {
    let a: Float64 = 1.0
    let b: Float64 = 2.0
    let max = max(a, b)
    println(max)
}

Running result:

2.000000

func max(Int16, Int16)

public func max(a: Int16, b: Int16): Int16

Description: Obtains the larger value between two numbers.

Parameters:

  • a: Int16: one number to be compared
  • b: Int16: the other number to be compared

Returns:

  • Int16: The larger value between the two numbers is returned.

Example:

import std.math.max

main() {
    let a: Int16 = -1
    let b: Int16 = 2
    let max = max(a, b)
    println(max)
}

Running result:

2

func max(Int32, Int32)

public func max(a: Int32, b: Int32): Int32

Description: Obtains the larger value between two numbers.

Parameters:

  • a: Int32: one number to be compared
  • b: Int32: the other number to be compared

Returns:

  • Int32: The larger value between the two numbers is returned.

Example:

import std.math.max

main() {
    let a: Int32 = -1
    let b: Int32 = 2
    let max = max(a, b)
    println(max)
}

Running result:

2

func max(Int64, Int64)

public func max(a: Int64, b: Int64): Int64

Description: Obtains the larger value between two numbers.

Parameters:

  • a: Int64: one number to be compared
  • b: Int64: the other number to be compared

Returns:

  • Int64: The larger value between the two numbers is returned.

Example:

import std.math.max

main() {
    let a: Int64 = -1
    let b: Int64 = 2
    let max = max(a, b)
    println(max)
}

Running result:

2

func max(Int8, Int8)

public func max(a: Int8, b: Int8): Int8

Description: Obtains the larger value between two numbers.

Parameters:

  • a: Int8: one number to be compared
  • b: Int8: the other number to be compared

Returns:

  • Int8: The larger value between the two numbers is returned.

Example:

import std.math.max

main() {
    let a: Int8 = -1
    let b: Int8 = 2
    let max = max(a, b)
    println(max)
}

Running result:

2

func max(UInt16, UInt16)

public func max(a: UInt16, b: UInt16): UInt16

Description: Obtains the larger value between two numbers.

Parameters:

  • a: UInt16: one number to be compared
  • b: UInt16: the other number to be compared

Returns:

  • UInt16: The larger value between the two numbers is returned.

Example:

import std.math.max

main() {
    let a: UInt16 = 1
    let b: UInt16 = 2
    let max = max(a, b)
    println(max)
}

Running result:

2

func max(UInt32, UInt32)

public func max(a: UInt32, b: UInt32): UInt32

Description: Obtains the larger value between two numbers.

Parameters:

  • a: UInt32: one number to be compared
  • b: UInt32: the other number to be compared

Returns:

  • UInt32: The larger value between the two numbers is returned.

Example:

import std.math.max

main() {
    let a: UInt32 = 1
    let b: UInt32 = 2
    let max = max(a, b)
    println(max)
}

Running result:

2

func max(UInt64, UInt64)

public func max(a: UInt64, b: UInt64): UInt64

Description: Obtains the larger value between two numbers.

Parameters:

  • a: UInt64: one number to be compared
  • b: UInt64: the other number to be compared

Returns:

  • UInt64: The larger value between the two numbers is returned.

Example:

import std.math.max

main() {
    let a: UInt64 = 1
    let b: UInt64 = 2
    let max = max(a, b)
    println(max)
}

Running result:

2

func max(UInt8, UInt8)

public func max(a: UInt8, b: UInt8): UInt8

Description: Obtains the larger value between two numbers.

Parameters:

  • a: UInt8: one number to be compared
  • b: UInt8: the other number to be compared

Returns:

  • UInt8: The larger value between the two numbers is returned.

Example:

import std.math.max

main() {
    let a: UInt8 = 1
    let b: UInt8 = 2
    let max = max(a, b)
    println(max)
}

Running result:

2

func maxNaN(Float16, Float16)

public func maxNaN(a: Float16, b: Float16): Float16

Description: Obtains the larger value between two numbers. maxNaN supports only floating-point numbers. If any input parameter is NaN, NaN is returned.

Parameters:

  • a: Float16: one number to be compared
  • b: Float16: the other number to be compared

Returns:

  • Float16: The larger value between the two numbers is returned. If any input parameter is NaN, NaN is returned.

Example:

import std.math.maxNaN

main() {
    let a: Float16 = 1.0
    let b: Float16 = 2.0
    let maxNaN = maxNaN(a, b)
    println(maxNaN)
}

Running result:

2.000000

func maxNaN(Float32, Float32)

public func maxNaN(a: Float32, b: Float32): Float32

Description: Obtains the larger value between two numbers. maxNaN supports only floating-point numbers. If any input parameter is NaN, NaN is returned.

Parameters:

  • a: Float32: one number to be compared
  • b: Float32: the other number to be compared

Returns:

  • Float32: The larger value between the two numbers is returned. If any input parameter is NaN, NaN is returned.

Example:

import std.math.maxNaN

main() {
    let a: Float32 = 1.0
    let b: Float32 = 2.0
    let maxNaN = maxNaN(a, b)
    println(maxNaN)
}

Running result:

2.000000

func maxNaN(Float64, Float64)

public func maxNaN(a: Float64, b: Float64): Float64

Description: Obtains the larger value between two numbers. maxNaN supports only floating-point numbers. If any input parameter is NaN, NaN is returned.

Parameters:

  • a: Float64: one number to be compared
  • b: Float64: the other number to be compared

Returns:

  • Float64: The larger value between the two numbers is returned. If any input parameter is NaN, NaN is returned.

Example:

import std.math.maxNaN

main() {
    let a: Float64 = 1.0
    let b: Float64 = 2.0
    let maxNaN = maxNaN(a, b)
    println(maxNaN)
}

Running result:

2.000000

func min(Float16, Float16)

public func min(a: Float16, b: Float16): Float16

Description: Obtains the smaller value between two numbers. If any input parameter is NaN, NaN is returned.

Parameters:

  • a: Float16: one number to be compared
  • b: Float16: the other number to be compared

Returns:

  • Float16: The smaller value between the two numbers is returned. If any input parameter is NaN, NaN is returned.

Example:

import std.math.min

main() {
    let a: Float16 = 1.0
    let b: Float16 = 2.0
    let min = min(a, b)
    println(min)
}

Running result:

1.000000

func min(Float32, Float32)

public func min(a: Float32, b: Float32): Float32

Description: Obtains the smaller value between two numbers. If any input parameter is NaN, NaN is returned.

Parameters:

  • a: Float32: one number to be compared
  • b: Float32: the other number to be compared

Returns:

  • Float32: The smaller value between the two numbers is returned. If any input parameter is NaN, NaN is returned.

Example:

import std.math.min

main() {
    let a: Float32 = 1.0
    let b: Float32 = 2.0
    let min = min(a, b)
    println(min)
}

Running result:

1.000000

func min(Float64, Float64)

public func min(a: Float64, b: Float64): Float64

Description: Obtains the smaller value between two numbers. If any input parameter is NaN, NaN is returned.

Parameters:

  • a: Float64: one number to be compared
  • b: Float64: the other number to be compared

Returns:

  • Float64: The smaller value between the two numbers is returned. If any input parameter is NaN, NaN is returned.

Example:

import std.math.min

main() {
    let a: Float64 = 1.0
    let b: Float64 = 2.0
    let min = min(a, b)
    println(min)
}

Running result:

1.000000

func min(Int16, Int16)

public func min(a: Int16, b: Int16): Int16

Description: Obtains the smaller value between two numbers.

Parameters:

  • a: Int16: one number to be compared
  • b: Int16: the other number to be compared

Returns:

  • Int16: The smaller value between the two numbers is returned.

Example:

import std.math.min

main() {
    let a: Int16 = -1
    let b: Int16 = 2
    let min = min(a, b)
    println(min)
}

Running result:

-1

func min(Int32, Int32)

public func min(a: Int32, b: Int32): Int32

Description: Obtains the smaller value between two numbers.

Parameters:

  • a: Int32: one number to be compared
  • b: Int32: the other number to be compared

Returns:

  • Int32: The smaller value between the two numbers is returned.

Example:

import std.math.min

main() {
    let a: Int32 = -1
    let b: Int32 = 2
    let min = min(a, b)
    println(min)
}

Running result:

-1

func min(Int64, Int64)

public func min(a: Int64, b: Int64): Int64

Description: Obtains the smaller value between two numbers.

Parameters:

  • a: Int64: one number to be compared
  • b: Int64: the other number to be compared

Returns:

  • Int64: The smaller value between the two numbers is returned.

Example:

import std.math.min

main() {
    let a: Int64 = -1
    let b: Int64 = 2
    let min = min(a, b)
    println(min)
}

Running result:

-1

func min(Int8, Int8)

public func min(a: Int8, b: Int8): Int8

Description: Obtains the smaller value between two numbers.

Parameters:

  • a: Int8: one number to be compared
  • b: Int8: the other number to be compared

Returns:

  • Int8: The smaller value between the two numbers is returned.

Example:

import std.math.min

main() {
    let a: Int8 = -1
    let b: Int8 = 2
    let min = min(a, b)
    println(min)
}

Running result:

-1

func min(UInt16, UInt16)

public func min(a: UInt16, b: UInt16): UInt16

Description: Obtains the smaller value between two numbers.

Parameters:

  • a: UInt16: one number to be compared
  • b: UInt16: the other number to be compared

Returns:

  • UInt16: The smaller value between the two numbers is returned.

Example:

import std.math.min

main() {
    let a: UInt16 = 1
    let b: UInt16 = 2
    let min = min(a, b)
    println(min)
}

Running result:

1

func min(UInt32, UInt32)

public func min(a: UInt32, b: UInt32): UInt32

Description: Obtains the smaller value between two numbers.

Parameters:

  • a: UInt32: one number to be compared
  • b: UInt32: the other number to be compared

Returns:

  • UInt32: The smaller value between the two numbers is returned.

Example:

import std.math.min

main() {
    let a: UInt32 = 1
    let b: UInt32 = 2
    let min = min(a, b)
    println(min)
}

Running result:

1

func min(UInt64, UInt64)

public func min(a: UInt64, b: UInt64): UInt64

Description: Obtains the smaller value between two numbers.

Parameters:

  • a: UInt64: one number to be compared
  • b: UInt64: the other number to be compared

Returns:

  • UInt64: The smaller value between the two numbers is returned.

Example:

import std.math.min

main() {
    let a: UInt64 = 1
    let b: UInt64 = 2
    let min = min(a, b)
    println(min)
}

Running result:

1

func min(UInt8, UInt8)

public func min(a: UInt8, b: UInt8): UInt8

Description: Obtains the smaller value between two numbers.

Parameters:

  • a: UInt8: one number to be compared
  • b: UInt8: the other number to be compared

Returns:

  • UInt8: The smaller value between the two numbers is returned.

Example:

import std.math.min

main() {
    let a: UInt8 = 1
    let b: UInt8 = 2
    let min = min(a, b)
    println(min)
}

Running result:

1

func minNaN(Float16, Float16)

public func minNaN(a: Float16, b: Float16): Float16

Description: Obtains the smaller value between two numbers. minNaN supports only floating-point numbers. If any input parameter is NaN, NaN is returned.

Parameters:

  • a: Float16: one number to be compared
  • b: Float16: the other number to be compared

Returns:

  • Float16: The smaller value between the two numbers is returned. If any input parameter is NaN, NaN is returned.

Example:

import std.math.minNaN

main() {
    let a: Float16 = 1.0
    let b: Float16 = 2.0
    let minNaN = minNaN(a, b)
    println(minNaN)
}

Running result:

1.000000

func minNaN(Float32, Float32)

public func minNaN(a: Float32, b: Float32): Float32

Description: Obtains the smaller value between two numbers. minNaN supports only floating-point numbers. If any input parameter is NaN, NaN is returned.

Parameters:

  • a: Float32: one number to be compared
  • b: Float32: the other number to be compared

Returns:

  • Float32: The smaller value between the two numbers is returned. If any input parameter is NaN, NaN is returned.

Example:

import std.math.minNaN

main() {
    let a: Float32 = 1.0
    let b: Float32 = 2.0
    let minNaN = minNaN(a, b)
    println(minNaN)
}

Running result:

1.000000

func minNaN(Float64, Float64)

public func minNaN(a: Float64, b: Float64): Float64

Description: Obtains the smaller value between two numbers. minNaN supports only floating-point numbers. If any input parameter is NaN, NaN is returned.

Parameters:

  • a: Float64: one number to be compared
  • b: Float64: the other number to be compared

Returns:

  • Float64: The smaller value between the two numbers is returned. If any input parameter is NaN, NaN is returned.

Example:

import std.math.minNaN

main() {
    let a: Float64 = 1.0
    let b: Float64 = 2.0
    let minNaN = minNaN(a, b)
    println(minNaN)
}

Running result:

1.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.

Example:

import std.math.pow

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

Running result:

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.

Example:

import std.math.pow

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

Running result:

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.

Example:

import std.math.pow

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

Running result:

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.

Example:

import std.math.pow

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

Running result:

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.

Example:

import std.math.reverse

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

Running result:

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.

Example:

import std.math.reverse

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

Running result:

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.

Example:

import std.math.reverse

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

Running result:

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.

Example:

import std.math.reverse

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

Running result:

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.

Example:

import std.math.rotate

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

Running result:

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.

Example:

import std.math.rotate

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

Running result:

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.

Example:

import std.math.rotate

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

Running result:

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.

Example:

import std.math.rotate

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

Running result:

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.

Example:

import std.math.rotate

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

Running result:

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.

Example:

import std.math.rotate

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

Running result:

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.

Example:

import std.math.rotate

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

Running result:

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.

Example:

import std.math.rotate

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

Running result:

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.

Example:

import std.math.round

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

Running result:

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.

Example:

import std.math.round

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

Running result:

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.

Example:

import std.math.round

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

Running result:

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.

Example:

import std.math.sin

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

Running result:

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.

Example:

import std.math.sin

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

Running result:

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.

Example:

import std.math.sin

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

Running result:

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.

Example:

import std.math.sinh

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

Running result:

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.

Example:

import std.math.sinh

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

Running result:

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.

Example:

import std.math.sinh

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

Running result:

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:

Example:

import std.math.sqrt

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

Running result:

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:

Example:

import std.math.sqrt

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

Running result:

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:

Example:

import std.math.sqrt

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

Running result:

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.

Example:

import std.math.tan

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

Running result:

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.

Example:

import std.math.tan

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

Running result:

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.

Example:

import std.math.tan

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

Running result:

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.

Example:

import std.math.tanh

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

Running result:

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.

Example:

import std.math.tanh

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

Running result:

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.

Example:

import std.math.tanh

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

Running result:

0.000000

func throwIllegalArgumentException()

public func throwIllegalArgumentException(): Int64

Description: This function is used to throw an invalid parameter exception.

Returns:

  • Int64: The value 0 is returned.

Throws:

func trailingZeros(Int16)

public func trailingZeros(x: Int16): Int8

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:

  • Int8: number of trailing zeros

Example:

import std.math.trailingZeros

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

Running result:

9

func trailingZeros(Int32)

public func trailingZeros(x: Int32): Int8

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:

  • Int8: number of trailing zeros

Example:

import std.math.trailingZeros

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

Running result:

9

func trailingZeros(Int64)

public func trailingZeros(x: Int64): Int8

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:

  • Int8: number of trailing zeros

Example:

import std.math.trailingZeros

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

Running result:

9

func trailingZeros(Int8)

public func trailingZeros(x: Int8): Int8

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:

  • Int8: number of trailing zeros

Example:

import std.math.trailingZeros

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

Running result:

6

func trailingZeros(UInt16)

public func trailingZeros(x: UInt16): Int8

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:

  • Int8: number of trailing zeros

Example:

import std.math.trailingZeros

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

Running result:

9

func trailingZeros(UInt32)

public func trailingZeros(x: UInt32): Int8

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:

  • Int8: number of trailing zeros

Example:

import std.math.trailingZeros

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

Running result:

9

func trailingZeros(UInt64)

public func trailingZeros(x: UInt64): Int8

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:

  • Int8: number of trailing zeros

Example:

import std.math.trailingZeros

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

Running result:

9

func trailingZeros(UInt8)

public func trailingZeros(x: UInt8): Int8

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:

  • Int8: number of trailing zeros

Example:

import std.math.trailingZeros

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

Running result:

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.

Example:

import std.math.trunc

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

Running result:

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.

Example:

import std.math.trunc

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

Running result:

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.

Example:

import std.math.trunc

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

Running result:

64.000000