Mathematical functions and constants.
The functions include trigonometric, hyperbolic, exponentiation and power, logarithmic, rounding, sign and absolute value.
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
Returns the absolute value of the given value x.
fun abs(x: Double): Double
Returns the absolute value of the given value n.
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
Computes the arc cosine of the value x; the returned value is an angle in the range from 0.0
to PI
radians.
fun acos(x: Double): Double
fun acos(x: Float): Float
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
Computes the inverse hyperbolic cosine of the value x.
fun acosh(x: Double): Double
fun acosh(x: Float): Float
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
Computes the arc sine of the value x; the returned value is an angle in the range from -PI/2
to PI/2
radians.
fun asin(x: Double): Double
fun asin(x: Float): Float
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
Computes the inverse hyperbolic sine of the value x.
fun asinh(x: Double): Double
fun asinh(x: Float): Float
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
Computes the arc tangent of the value x; the returned value is an angle in the range from -PI/2
to PI/2
radians.
fun atan(x: Double): Double
fun atan(x: Float): Float
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
Returns the angle theta
of the polar coordinates (r, theta)
that correspond to the rectangular coordinates (x, y)
by computing the arc tangent of the value y / x; the returned value is an angle in the range from -PI
to PI
radians.
fun atan2(y: Double, x: Double): Double
fun atan2(y: Float, x: Float): Float
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
Computes the inverse hyperbolic tangent of the value x.
fun atanh(x: Double): Double
fun atanh(x: Float): Float
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
Rounds the given value x to an integer towards positive infinity.
fun ceil(x: Double): Double
fun ceil(x: Float): Float
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
Computes the cosine of the angle x given in radians.
fun cos(x: Double): Double
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
Computes the hyperbolic cosine of the value x.
fun cosh(x: Double): Double
fun cosh(x: Float): Float
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
Computes Euler's number e
raised to the power of the value x.
fun exp(x: Double): Double
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
Computes exp(x) - 1
.
fun expm1(x: Double): Double
fun expm1(x: Float): Float
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
Rounds the given value x to an integer towards negative infinity.
fun floor(x: Double): Double
fun floor(x: Float): Float
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
Computes sqrt(x^2 + y^2)
without intermediate overflow or underflow.
fun hypot(x: Double, y: Double): Double
fun hypot(x: Float, y: Float): Float
Platform and version requirements: JVM (1.2), Native (1.2)
Computes the remainder of division of this value by the divisor value according to the IEEE 754 standard.
fun Double.IEEErem(divisor: Double): Double
fun Float.IEEErem(divisor: Float): Float
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
Computes the natural logarithm (base E
) of the value x.
fun ln(x: Double): Double
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
Computes ln(x + 1)
.
fun ln1p(x: Double): Double
Computes ln(a + 1)
.
fun ln1p(x: Float): Float
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
Computes the logarithm of the value x to the given base.
fun log(x: Double, base: Double): Double
fun log(x: Float, base: Float): Float
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
Computes the common logarithm (base 10) of the value x.
fun log10(x: Double): Double
fun log10(x: Float): Float
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
Computes the binary logarithm (base 2) of the value x.
fun log2(x: Double): Double
fun log2(x: Float): Float
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
Returns the greater of two values.
fun max(a: UInt, b: UInt): UInt
fun max(a: ULong, b: ULong): ULong
fun max(a: Double, b: Double): Double
fun max(a: Float, b: Float): Float
fun max(a: Int, b: Int): Int
fun max(a: Long, b: Long): Long
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
Returns the smaller of two values.
fun min(a: UInt, b: UInt): UInt
fun min(a: ULong, b: ULong): ULong
fun min(a: Double, b: Double): Double
fun min(a: Float, b: Float): Float
fun min(a: Int, b: Int): Int
fun min(a: Long, b: Long): Long
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
Returns the Double value nearest to this value in direction of negative infinity.
fun Double.nextDown(): Double
Platform and version requirements: JVM (1.2), Native (1.2)
Returns the Float value nearest to this value in direction of negative infinity.
fun Float.nextDown(): Float
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
Returns the Double value nearest to this value in direction from this value towards the value to.
fun Double.nextTowards(to: Double): Double
Platform and version requirements: JVM (1.2), Native (1.2)
Returns the Float value nearest to this value in direction from this value towards the value to.
fun Float.nextTowards(to: Float): Float
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
Returns the Double value nearest to this value in direction of positive infinity.
fun Double.nextUp(): Double
Platform and version requirements: JVM (1.2), Native (1.2)
Returns the Float value nearest to this value in direction of positive infinity.
fun Float.nextUp(): Float
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
Raises this value to the power x.
fun Double.pow(x: Double): Double
fun Float.pow(x: Float): Float
Raises this value to the integer power n.
fun Double.pow(n: Int): Double
fun Float.pow(n: Int): Float
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
Rounds the given value x towards the closest integer with ties rounded towards even integer.
fun round(x: Double): Double
fun round(x: Float): Float
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
Rounds this Double value to the nearest integer and converts the result to Int. Ties are rounded towards positive infinity.
fun Double.roundToInt(): Int
Rounds this Float value to the nearest integer and converts the result to Int. Ties are rounded towards positive infinity.
fun Float.roundToInt(): Int
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
Rounds this Double value to the nearest integer and converts the result to Long. Ties are rounded towards positive infinity.
fun Double.roundToLong(): Long
Rounds this Float value to the nearest integer and converts the result to Long. Ties are rounded towards positive infinity.
fun Float.roundToLong(): Long
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
Returns the sign of the given value x:
fun sign(x: Double): Double
fun sign(x: Float): Float
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
Computes the sine of the angle x given in radians.
fun sin(x: Double): Double
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
Computes the hyperbolic sine of the value x.
fun sinh(x: Double): Double
fun sinh(x: Float): Float
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
Computes the positive square root of the value x.
fun sqrt(x: Double): Double
fun sqrt(x: Float): Float
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
Computes the tangent of the angle x given in radians.
fun tan(x: Double): Double
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
Computes the hyperbolic tangent of the value x.
fun tanh(x: Double): Double
fun tanh(x: Float): Float
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
Rounds the given value x to an integer towards zero.
fun truncate(x: Double): Double
fun truncate(x: Float): Float
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
Returns this value with the sign bit same as of the sign value.
fun Double.withSign(sign: Double): Double
fun Double.withSign(sign: Int): Double
fun Float.withSign(sign: Float): Float
fun Float.withSign(sign: Int): Float