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: Double
val Float.absoluteValue: Float
val Int.absoluteValue: Int
val Long.absoluteValue: Long
E
Base of the natural logarithms, approximately 2.71828.
const val E: Double
PI
Ratio of the circumference of a circle to its diameter, approximately 3.14159.
const val PI: Double
sign
Returns the sign of this value:
val Double.sign: Double
val Float.sign: Float
val Int.sign: Int
val Long.sign: Int
ulp
Returns the ulp (unit in the last place) of this value.
val Double.ulp: Double
Returns the ulp of this value.
val Float.ulp: Float
Functions
abs
Returns the absolute value of the given value x.
fun abs(x: Double): Double
fun abs(x: Float): Float
acos
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
acosh
Computes the inverse hyperbolic cosine of the value x.
fun acosh(x: Double): Double
fun acosh(x: Float): Float
asin
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
asinh
Computes the inverse hyperbolic sine of the value x.
fun asinh(x: Double): Double
fun asinh(x: Float): Float
atan
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
atan2
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
atanh
Computes the inverse hyperbolic tangent of the value x.
fun atanh(x: Double): Double
fun atanh(x: Float): Float
ceil
Rounds the given value x to an integer towards positive infinity.
fun ceil(x: Double): Double
fun ceil(x: Float): Float
cos
Computes the cosine of the angle x given in radians.
fun cos(x: Double): Double
fun cos(x: Float): Float
cosh
Computes the hyperbolic cosine of the value x.
fun cosh(x: Double): Double
fun cosh(x: Float): Float
exp
Computes Euler's number e
raised to the power of the value x.
fun exp(x: Double): Double
fun exp(x: Float): Float
expm1
Computes exp(x) - 1
.
fun expm1(x: Double): Double
fun expm1(x: Float): Float
floor
Rounds the given value x to an integer towards negative infinity.
fun floor(x: Double): Double
fun floor(x: Float): Float
hypot
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
IEEErem
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
ln
Computes the natural logarithm (base E
) of the value x.
fun ln(x: Double): Double
fun ln(x: Float): Float
log10
Computes the common logarithm (base 10) of the value x.
fun log10(x: Double): Double
fun log10(x: Float): Float
log2
Computes the binary logarithm (base 2) of the value x.
fun log2(x: Double): Double
fun log2(x: Float): Float
nextDown
Returns the Double value nearest to this value in direction of negative infinity.
fun Double.nextDown(): Double
Returns the Float value nearest to this value in direction of negative infinity.
fun Float.nextDown(): Float
nextTowards
nextUp
Returns the Double value nearest to this value in direction of positive infinity.
fun Double.nextUp(): Double
Returns the Float value nearest to this value in direction of positive infinity.
fun Float.nextUp(): Float
pow
Raises this value to the integer power n.
fun Double.pow(n: Int): Double
fun Float.pow(n: Int): Float
round
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
roundToInt
roundToLong
sin
Computes the sine of the angle x given in radians.
fun sin(x: Double): Double
fun sin(x: Float): Float
sqrt
Computes the positive square root of the value x.
fun sqrt(x: Double): Double
fun sqrt(x: Float): Float
tan
Computes the tangent of the angle x given in radians.
fun tan(x: Double): Double
fun tan(x: Float): Float
tanh
Computes the hyperbolic tangent of the value x.
fun tanh(x: Double): Double
fun tanh(x: Float): Float