Package kotlin.math
Mathematical functions and constants.
The functions include trigonometric, hyperbolic, exponentiation and power, logarithmic, rounding, sign and absolute value.
Properties
absoluteValue
Returns the absolute value of this value.
val Double.absoluteValue: Doubleval Float.absoluteValue: Floatval Int.absoluteValue: Intval Long.absoluteValue: LongE
Base of the natural logarithms, approximately 2.71828.
const val E: DoublePI
Ratio of the circumference of a circle to its diameter, approximately 3.14159.
const val PI: Doublesign
Returns the sign of this value:
val Double.sign: Doubleval Float.sign: Floatval Int.sign: Intval Long.sign: Intulp
Returns the ulp (unit in the last place) of this value.
val Double.ulp: DoubleReturns the ulp of this value.
val Float.ulp: FloatFunctions
abs
Returns the absolute value of the given value x.
fun abs(x: Double): Doublefun abs(x: Float): Floatacos
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): Doublefun acos(x: Float): Floatacosh
Computes the inverse hyperbolic cosine of the value x.
fun acosh(x: Double): Doublefun acosh(x: Float): Floatasin
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): Doublefun asin(x: Float): Floatasinh
Computes the inverse hyperbolic sine of the value x.
fun asinh(x: Double): Doublefun asinh(x: Float): Floatatan
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): Doublefun atan(x: Float): Floatatan2
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): Doublefun atan2(y: Float, x: Float): Floatatanh
Computes the inverse hyperbolic tangent of the value x.
fun atanh(x: Double): Doublefun atanh(x: Float): Floatceil
Rounds the given value x to an integer towards positive infinity.
fun ceil(x: Double): Doublefun ceil(x: Float): Floatcos
Computes the cosine of the angle x given in radians.
fun cos(x: Double): Doublefun cos(x: Float): Floatcosh
Computes the hyperbolic cosine of the value x.
fun cosh(x: Double): Doublefun cosh(x: Float): Floatexp
Computes Euler's number e raised to the power of the value x.
fun exp(x: Double): Doublefun exp(x: Float): Floatexpm1
Computes exp(x) - 1.
fun expm1(x: Double): Doublefun expm1(x: Float): Floatfloor
Rounds the given value x to an integer towards negative infinity.
fun floor(x: Double): Doublefun floor(x: Float): Floathypot
Computes sqrt(x^2 + y^2) without intermediate overflow or underflow.
fun hypot(x: Double, y: Double): Doublefun hypot(x: Float, y: Float): FloatIEEErem
Computes the remainder of division of this value by the divisor value according to the IEEE 754 standard.
fun Double.IEEErem(divisor: Double): Doublefun Float.IEEErem(divisor: Float): Floatln
Computes the natural logarithm (base E) of the value x.
fun ln(x: Double): Doublefun ln(x: Float): Floatlog10
Computes the common logarithm (base 10) of the value x.
fun log10(x: Double): Doublefun log10(x: Float): Floatlog2
Computes the binary logarithm (base 2) of the value x.
fun log2(x: Double): Doublefun log2(x: Float): FloatnextDown
Returns the Double value nearest to this value in direction of negative infinity.
fun Double.nextDown(): DoubleReturns the Float value nearest to this value in direction of negative infinity.
fun Float.nextDown(): FloatnextTowards
nextUp
Returns the Double value nearest to this value in direction of positive infinity.
fun Double.nextUp(): DoubleReturns the Float value nearest to this value in direction of positive infinity.
fun Float.nextUp(): Floatpow
Raises this value to the integer power n.
fun Double.pow(n: Int): Doublefun Float.pow(n: Int): Floatround
Rounds the given value x towards the closest integer with ties rounded towards even integer.
fun round(x: Double): Doublefun round(x: Float): FloatroundToInt
roundToLong
sin
Computes the sine of the angle x given in radians.
fun sin(x: Double): Doublefun sin(x: Float): Floatsqrt
Computes the positive square root of the value x.
fun sqrt(x: Double): Doublefun sqrt(x: Float): Floattan
Computes the tangent of the angle x given in radians.
fun tan(x: Double): Doublefun tan(x: Float): Floattanh
Computes the hyperbolic tangent of the value x.
fun tanh(x: Double): Doublefun tanh(x: Float): Float