Finalize math function parameter names

#KT-4900
This commit is contained in:
Ilya Gorbunov
2017-10-24 22:17:33 +03:00
parent bbcf4f7caf
commit ace9d0da94
3 changed files with 481 additions and 481 deletions
+154 -154
View File
@@ -31,57 +31,57 @@ public const val E: Double = 2.718281828459045
// ================ Double Math ========================================
/** Computes the sine of the angle [a] given in radians.
/** Computes the sine of the angle [x] given in radians.
*
* Special cases:
* - `sin(NaN|+Inf|-Inf)` is `NaN`
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun sin(a: Double): Double = nativeMath.sin(a)
public inline fun sin(x: Double): Double = nativeMath.sin(x)
/** Computes the cosine of the angle [a] given in radians.
/** Computes the cosine of the angle [x] given in radians.
*
* Special cases:
* - `cos(NaN|+Inf|-Inf)` is `NaN`
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun cos(a: Double): Double = nativeMath.cos(a)
public inline fun cos(x: Double): Double = nativeMath.cos(x)
/** Computes the tangent of the angle [a] given in radians.
/** Computes the tangent of the angle [x] given in radians.
*
* Special cases:
* - `tan(NaN|+Inf|-Inf)` is `NaN`
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun tan(a: Double): Double = nativeMath.tan(a)
public inline fun tan(x: Double): Double = nativeMath.tan(x)
/**
* Computes the arc sine of the value [a];
* Computes the arc sine of the value [x];
* the returned value is an angle in the range from `-PI/2` to `PI/2` radians.
*
* Special cases:
* - `asin(v)` is `NaN`, when `abs(v) > 1` or v is `NaN`
* - `asin(x)` is `NaN`, when `abs(x) > 1` or x is `NaN`
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun asin(a: Double): Double = nativeMath.asin(a)
public inline fun asin(x: Double): Double = nativeMath.asin(x)
/**
* Computes the arc cosine of the value [a];
* Computes the arc cosine of the value [x];
* the returned value is an angle in the range from `0.0` to `PI` radians.
*
* Special cases:
* - `acos(v)` is `NaN`, when `abs(v) > 1` or v is `NaN`
* - `acos(x)` is `NaN`, when `abs(x) > 1` or x is `NaN`
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun acos(a: Double): Double = nativeMath.acos(a)
public inline fun acos(x: Double): Double = nativeMath.acos(x)
/**
* Computes the arc tangent of the value [a];
* Computes the arc tangent of the value [x];
* the returned value is an angle in the range from `-PI/2` to `PI/2` radians.
*
* Special cases:
@@ -89,7 +89,7 @@ public inline fun acos(a: Double): Double = nativeMath.acos(a)
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun atan(a: Double): Double = nativeMath.atan(a)
public inline fun atan(x: Double): Double = nativeMath.atan(x)
/**
* Returns the angle `theta` of the polar coordinates `(r, theta)` that correspond
@@ -112,7 +112,7 @@ public inline fun atan(a: Double): Double = nativeMath.atan(a)
public inline fun atan2(y: Double, x: Double): Double = nativeMath.atan2(y, x)
/**
* Computes the hyperbolic sine of the value [a].
* Computes the hyperbolic sine of the value [x].
*
* Special cases:
* - `sinh(NaN)` is `NaN`
@@ -121,10 +121,10 @@ public inline fun atan2(y: Double, x: Double): Double = nativeMath.atan2(y, x)
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun sinh(a: Double): Double = nativeMath.sinh(a)
public inline fun sinh(x: Double): Double = nativeMath.sinh(x)
/**
* Computes the hyperbolic cosine of the value [a].
* Computes the hyperbolic cosine of the value [x].
*
* Special cases:
* - `cosh(NaN)` is `NaN`
@@ -132,10 +132,10 @@ public inline fun sinh(a: Double): Double = nativeMath.sinh(a)
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun cosh(a: Double): Double = nativeMath.cosh(a)
public inline fun cosh(x: Double): Double = nativeMath.cosh(x)
/**
* Computes the hyperbolic tangent of the value [a].
* Computes the hyperbolic tangent of the value [x].
*
* Special cases:
* - `tanh(NaN)` is `NaN`
@@ -144,12 +144,12 @@ public inline fun cosh(a: Double): Double = nativeMath.cosh(a)
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun tanh(a: Double): Double = nativeMath.tanh(a)
public inline fun tanh(x: Double): Double = nativeMath.tanh(x)
/**
* Computes the inverse hyperbolic sine of the value [a].
* Computes the inverse hyperbolic sine of the value [x].
*
* The returned value is `x` such that `sinh(x) == a`.
* The returned value is `y` such that `sinh(y) == x`.
*
* Special cases:
* - `asinh(NaN)` is `NaN`
@@ -158,12 +158,12 @@ public inline fun tanh(a: Double): Double = nativeMath.tanh(a)
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun asinh(a: Double): Double = nativeMath.asinh(a)
public inline fun asinh(x: Double): Double = nativeMath.asinh(x)
/**
* Computes the inverse hyperbolic cosine of the value [a].
* Computes the inverse hyperbolic cosine of the value [x].
*
* The returned value is positive `x` such that `cosh(x) == a`.
* The returned value is positive `y` such that `cosh(y) == x`.
*
* Special cases:
* - `acosh(NaN)` is `NaN`
@@ -172,12 +172,12 @@ public inline fun asinh(a: Double): Double = nativeMath.asinh(a)
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun acosh(a: Double): Double = nativeMath.acosh(a)
public inline fun acosh(x: Double): Double = nativeMath.acosh(x)
/**
* Computes the inverse hyperbolic tangent of the value [a].
* Computes the inverse hyperbolic tangent of the value [x].
*
* The returned value is `x` such that `tanh(x) == a`.
* The returned value is `y` such that `tanh(y) == x`.
*
* Special cases:
* - `tanh(NaN)` is `NaN`
@@ -187,7 +187,7 @@ public inline fun acosh(a: Double): Double = nativeMath.acosh(a)
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun atanh(a: Double): Double = nativeMath.atanh(a)
public inline fun atanh(x: Double): Double = nativeMath.atanh(x)
/**
* Computes `sqrt(x^2 + y^2)` without intermediate overflow or underflow.
@@ -201,17 +201,17 @@ public inline fun atanh(a: Double): Double = nativeMath.atanh(a)
public inline fun hypot(x: Double, y: Double): Double = nativeMath.hypot(x, y)
/**
* Computes the positive square root of the value [a].
* Computes the positive square root of the value [x].
*
* Special cases:
* - `sqrt(x)` is `NaN` when `x < 0` or `x` is `NaN`
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun sqrt(a: Double): Double = nativeMath.sqrt(a)
public inline fun sqrt(x: Double): Double = nativeMath.sqrt(x)
/**
* Computes Euler's number `e` raised to the power of the value [a].
* Computes Euler's number `e` raised to the power of the value [x].
*
* Special cases:
* - `exp(NaN)` is `NaN`
@@ -220,12 +220,12 @@ public inline fun sqrt(a: Double): Double = nativeMath.sqrt(a)
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun exp(a: Double): Double = nativeMath.exp(a)
public inline fun exp(x: Double): Double = nativeMath.exp(x)
/**
* Computes `exp(a) - 1`.
* Computes `exp(x) - 1`.
*
* This function can be implemented to produce more precise result for [a] near zero.
* This function can be implemented to produce more precise result for [x] near zero.
*
* Special cases:
* - `expm1(NaN)` is `NaN`
@@ -236,14 +236,14 @@ public inline fun exp(a: Double): Double = nativeMath.exp(a)
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun expm1(a: Double): Double = nativeMath.expm1(a)
public inline fun expm1(x: Double): Double = nativeMath.expm1(x)
/**
* Computes the logarithm of the value [a] to the given [base].
* Computes the logarithm of the value [x] to the given [base].
*
* Special cases:
* - `log(a, b)` is `NaN` if either `a` or `b` are `NaN`
* - `log(a, b)` is `NaN` when `a < 0` or `b <= 0` or `b == 1.0`
* - `log(x, b)` is `NaN` if either `x` or `b` are `NaN`
* - `log(x, b)` is `NaN` when `x < 0` or `b <= 0` or `b == 1.0`
* - `log(+Inf, +Inf)` is `NaN`
* - `log(+Inf, b)` is `+Inf` for `b > 1` and `-Inf` for `b < 1`
* - `log(0.0, b)` is `-Inf` for `b > 1` and `+Inf` for `b > 1`
@@ -251,13 +251,13 @@ public inline fun expm1(a: Double): Double = nativeMath.expm1(a)
* See also logarithm functions for common fixed bases: [ln], [log10] and [log2].
*/
@SinceKotlin("1.2")
public fun log(a: Double, base: Double): Double {
public fun log(x: Double, base: Double): Double {
if (base <= 0.0 || base == 1.0) return Double.NaN
return nativeMath.log(a) / nativeMath.log(base)
return nativeMath.log(x) / nativeMath.log(base)
}
/**
* Computes the natural logarithm (base `E`) of the value [a].
* Computes the natural logarithm (base `E`) of the value [x].
*
* Special cases:
* - `ln(NaN)` is `NaN`
@@ -267,30 +267,30 @@ public fun log(a: Double, base: Double): Double {
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun ln(a: Double): Double = nativeMath.log(a)
public inline fun ln(x: Double): Double = nativeMath.log(x)
/**
* Computes the common logarithm (base 10) of the value [a].
* Computes the common logarithm (base 10) of the value [x].
*
* @see [ln] function for special cases.
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun log10(a: Double): Double = nativeMath.log10(a)
public inline fun log10(x: Double): Double = nativeMath.log10(x)
/**
* Computes the binary logarithm (base 2) of the value [a].
* Computes the binary logarithm (base 2) of the value [x].
*
* @see [ln] function for special cases.
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun log2(a: Double): Double = nativeMath.log2(a)
public inline fun log2(x: Double): Double = nativeMath.log2(x)
/**
* Computes `ln(a + 1)`.
* Computes `ln(x + 1)`.
*
* This function can be implemented to produce more precise result for [a] near zero.
* This function can be implemented to produce more precise result for [x] near zero.
*
* Special cases:
* - `ln1p(NaN)` is `NaN`
@@ -303,61 +303,61 @@ public inline fun log2(a: Double): Double = nativeMath.log2(a)
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun ln1p(a: Double): Double = nativeMath.log1p(a)
public inline fun ln1p(x: Double): Double = nativeMath.log1p(x)
/**
* Rounds the given value [a] to an integer towards positive infinity.
* Rounds the given value [x] to an integer towards positive infinity.
* @return the smallest double value that is greater than the given value [a] and is a mathematical integer.
* @return the smallest double value that is greater than the given value [x] and is a mathematical integer.
*
* Special cases:
* - `ceil(x)` is `x` where `x` is `NaN` or `+Inf` or `-Inf` or already a mathematical integer.
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun ceil(a: Double): Double = nativeMath.ceil(a).unsafeCast<Double>() // TODO: Remove unsafe cast after removing public js.math
public inline fun ceil(x: Double): Double = nativeMath.ceil(x).unsafeCast<Double>() // TODO: Remove unsafe cast after removing public js.math
/**
* Rounds the given value [a] to an integer towards negative infinity.
* Rounds the given value [x] to an integer towards negative infinity.
* @return the largest double value that is smaller than the given value [a] and is a mathematical integer.
* @return the largest double value that is smaller than the given value [x] and is a mathematical integer.
*
* Special cases:
* - `floor(x)` is `x` where `x` is `NaN` or `+Inf` or `-Inf` or already a mathematical integer.
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun floor(a: Double): Double = nativeMath.floor(a).unsafeCast<Double>()
public inline fun floor(x: Double): Double = nativeMath.floor(x).unsafeCast<Double>()
/**
* Rounds the given value [a] to an integer towards zero.
* Rounds the given value [x] to an integer towards zero.
*
* @return the value [a] having its fractional part truncated.
* @return the value [x] having its fractional part truncated.
*
* Special cases:
* - `truncate(x)` is `x` where `x` is `NaN` or `+Inf` or `-Inf` or already a mathematical integer.
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun truncate(a: Double): Double = nativeMath.trunc(a)
public inline fun truncate(x: Double): Double = nativeMath.trunc(x)
/**
* Rounds the given value [a] towards the closest integer with ties rounded towards even integer.
* Rounds the given value [x] towards the closest integer with ties rounded towards even integer.
*
* Special cases:
* - `round(x)` is `x` where `x` is `NaN` or `+Inf` or `-Inf` or already a mathematical integer.
*/
@SinceKotlin("1.2")
public fun round(a: Double): Double {
if (a % 0.5 != 0.0) {
return nativeMath.round(a).unsafeCast<Double>()
public fun round(x: Double): Double {
if (x % 0.5 != 0.0) {
return nativeMath.round(x).unsafeCast<Double>()
}
val floor = floor(a)
return if (floor % 2 == 0.0) floor else ceil(a)
val floor = floor(x)
return if (floor % 2 == 0.0) floor else ceil(x)
}
/**
* Returns the absolute value of the given value [a].
* Returns the absolute value of the given value [x].
*
* Special cases:
* - `abs(NaN)` is `NaN`
@@ -366,10 +366,10 @@ public fun round(a: Double): Double {
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun abs(a: Double): Double = nativeMath.abs(a)
public inline fun abs(x: Double): Double = nativeMath.abs(x)
/**
* Returns the sign of the given value [a]:
* Returns the sign of the given value [x]:
* - `-1.0` if the value is negative,
* - zero if the value is zero,
* - `1.0` if the value is positive
@@ -379,7 +379,7 @@ public inline fun abs(a: Double): Double = nativeMath.abs(a)
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun sign(a: Double): Double = nativeMath.sign(a)
public inline fun sign(x: Double): Double = nativeMath.sign(x)
/**
@@ -402,28 +402,28 @@ public inline fun max(a: Double, b: Double): Double = nativeMath.max(a, b)
// extensions
/**
* Raises this value to the power [other].
* Raises this value to the power [x].
*
* Special cases:
* - `x.pow(0.0)` is `1.0`
* - `x.pow(1.0) == x`
* - `x.pow(NaN)` is `NaN`
* - `b.pow(0.0)` is `1.0`
* - `b.pow(1.0) == b`
* - `b.pow(NaN)` is `NaN`
* - `NaN.pow(x)` is `NaN` for `x != 0.0`
* - `x.pow(Inf)` is `NaN` for `abs(x) == 1.0`
* - `x.pow(y)` is `NaN` for `x < 0` and `y` is finite and not an integer
* - `b.pow(Inf)` is `NaN` for `abs(b) == 1.0`
* - `b.pow(x)` is `NaN` for `b < 0` and `x` is finite and not an integer
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun Double.pow(other: Double): Double = nativeMath.pow(this, other)
public inline fun Double.pow(x: Double): Double = nativeMath.pow(this, x)
/**
* Raises this value to the integer power [other].
* Raises this value to the integer power [n].
*
* See the other overload of [pow] for details.
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun Double.pow(other: Int): Double = nativeMath.pow(this, other.toDouble())
public inline fun Double.pow(n: Int): Double = nativeMath.pow(this, n.toDouble())
/**
* Returns the absolute value of this value.
@@ -566,57 +566,57 @@ public fun Double.roundToLong(): Long = when {
// ================ Float Math ========================================
/** Computes the sine of the angle [a] given in radians.
/** Computes the sine of the angle [x] given in radians.
*
* Special cases:
* - `sin(NaN|+Inf|-Inf)` is `NaN`
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun sin(a: Float): Float = nativeMath.sin(a.toDouble()).toFloat()
public inline fun sin(x: Float): Float = nativeMath.sin(x.toDouble()).toFloat()
/** Computes the cosine of the angle [a] given in radians.
/** Computes the cosine of the angle [x] given in radians.
*
* Special cases:
* - `cos(NaN|+Inf|-Inf)` is `NaN`
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun cos(a: Float): Float = nativeMath.cos(a.toDouble()).toFloat()
public inline fun cos(x: Float): Float = nativeMath.cos(x.toDouble()).toFloat()
/** Computes the tangent of the angle [a] given in radians.
/** Computes the tangent of the angle [x] given in radians.
*
* Special cases:
* - `tan(NaN|+Inf|-Inf)` is `NaN`
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun tan(a: Float): Float = nativeMath.tan(a.toDouble()).toFloat()
public inline fun tan(x: Float): Float = nativeMath.tan(x.toDouble()).toFloat()
/**
* Computes the arc sine of the value [a];
* Computes the arc sine of the value [x];
* the returned value is an angle in the range from `-PI/2` to `PI/2` radians.
*
* Special cases:
* - `asin(v)` is `NaN`, when `abs(v) > 1` or v is `NaN`
* - `asin(x)` is `NaN`, when `abs(x) > 1` or x is `NaN`
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun asin(a: Float): Float = nativeMath.asin(a.toDouble()).toFloat()
public inline fun asin(x: Float): Float = nativeMath.asin(x.toDouble()).toFloat()
/**
* Computes the arc cosine of the value [a];
* Computes the arc cosine of the value [x];
* the returned value is an angle in the range from `0.0` to `PI` radians.
*
* Special cases:
* - `acos(v)` is `NaN`, when `abs(v) > 1` or v is `NaN`
* - `acos(x)` is `NaN`, when `abs(x) > 1` or x is `NaN`
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun acos(a: Float): Float = nativeMath.acos(a.toDouble()).toFloat()
public inline fun acos(x: Float): Float = nativeMath.acos(x.toDouble()).toFloat()
/**
* Computes the arc tangent of the value [a];
* Computes the arc tangent of the value [x];
* the returned value is an angle in the range from `-PI/2` to `PI/2` radians.
*
* Special cases:
@@ -624,7 +624,7 @@ public inline fun acos(a: Float): Float = nativeMath.acos(a.toDouble()).toFloat(
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun atan(a: Float): Float = nativeMath.atan(a.toDouble()).toFloat()
public inline fun atan(x: Float): Float = nativeMath.atan(x.toDouble()).toFloat()
/**
* Returns the angle `theta` of the polar coordinates `(r, theta)` that correspond
@@ -647,7 +647,7 @@ public inline fun atan(a: Float): Float = nativeMath.atan(a.toDouble()).toFloat(
public inline fun atan2(y: Float, x: Float): Float = nativeMath.atan2(y.toDouble(), x.toDouble()).toFloat()
/**
* Computes the hyperbolic sine of the value [a].
* Computes the hyperbolic sine of the value [x].
*
* Special cases:
* - `sinh(NaN)` is `NaN`
@@ -656,10 +656,10 @@ public inline fun atan2(y: Float, x: Float): Float = nativeMath.atan2(y.toDouble
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun sinh(a: Float): Float = nativeMath.sinh(a.toDouble()).toFloat()
public inline fun sinh(x: Float): Float = nativeMath.sinh(x.toDouble()).toFloat()
/**
* Computes the hyperbolic cosine of the value [a].
* Computes the hyperbolic cosine of the value [x].
*
* Special cases:
* - `cosh(NaN)` is `NaN`
@@ -667,10 +667,10 @@ public inline fun sinh(a: Float): Float = nativeMath.sinh(a.toDouble()).toFloat(
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun cosh(a: Float): Float = nativeMath.cosh(a.toDouble()).toFloat()
public inline fun cosh(x: Float): Float = nativeMath.cosh(x.toDouble()).toFloat()
/**
* Computes the hyperbolic tangent of the value [a].
* Computes the hyperbolic tangent of the value [x].
*
* Special cases:
* - `tanh(NaN)` is `NaN`
@@ -679,12 +679,12 @@ public inline fun cosh(a: Float): Float = nativeMath.cosh(a.toDouble()).toFloat(
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun tanh(a: Float): Float = nativeMath.tanh(a.toDouble()).toFloat()
public inline fun tanh(x: Float): Float = nativeMath.tanh(x.toDouble()).toFloat()
/**
* Computes the inverse hyperbolic sine of the value [a].
* Computes the inverse hyperbolic sine of the value [x].
*
* The returned value is `x` such that `sinh(x) == a`.
* The returned value is `y` such that `sinh(y) == x`.
*
* Special cases:
* - `asinh(NaN)` is `NaN`
@@ -693,12 +693,12 @@ public inline fun tanh(a: Float): Float = nativeMath.tanh(a.toDouble()).toFloat(
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun asinh(a: Float): Float = nativeMath.asinh(a.toDouble()).toFloat()
public inline fun asinh(x: Float): Float = nativeMath.asinh(x.toDouble()).toFloat()
/**
* Computes the inverse hyperbolic cosine of the value [a].
* Computes the inverse hyperbolic cosine of the value [x].
*
* The returned value is positive `x` such that `cosh(x) == a`.
* The returned value is positive `y` such that `cosh(y) == x`.
*
* Special cases:
* - `acosh(NaN)` is `NaN`
@@ -707,12 +707,12 @@ public inline fun asinh(a: Float): Float = nativeMath.asinh(a.toDouble()).toFloa
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun acosh(a: Float): Float = nativeMath.acosh(a.toDouble()).toFloat()
public inline fun acosh(x: Float): Float = nativeMath.acosh(x.toDouble()).toFloat()
/**
* Computes the inverse hyperbolic tangent of the value [a].
* Computes the inverse hyperbolic tangent of the value [x].
*
* The returned value is `x` such that `tanh(x) == a`.
* The returned value is `y` such that `tanh(y) == x`.
*
* Special cases:
* - `tanh(NaN)` is `NaN`
@@ -722,7 +722,7 @@ public inline fun acosh(a: Float): Float = nativeMath.acosh(a.toDouble()).toFloa
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun atanh(a: Float): Float = nativeMath.atanh(a.toDouble()).toFloat()
public inline fun atanh(x: Float): Float = nativeMath.atanh(x.toDouble()).toFloat()
/**
* Computes `sqrt(x^2 + y^2)` without intermediate overflow or underflow.
@@ -736,17 +736,17 @@ public inline fun atanh(a: Float): Float = nativeMath.atanh(a.toDouble()).toFloa
public inline fun hypot(x: Float, y: Float): Float = nativeMath.hypot(x.toDouble(), y.toDouble()).toFloat()
/**
* Computes the positive square root of the value [a].
* Computes the positive square root of the value [x].
*
* Special cases:
* - `sqrt(x)` is `NaN` when `x < 0` or `x` is `NaN`
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun sqrt(a: Float): Float = nativeMath.sqrt(a.toDouble()).toFloat()
public inline fun sqrt(x: Float): Float = nativeMath.sqrt(x.toDouble()).toFloat()
/**
* Computes Euler's number `e` raised to the power of the value [a].
* Computes Euler's number `e` raised to the power of the value [x].
*
* Special cases:
* - `exp(NaN)` is `NaN`
@@ -755,12 +755,12 @@ public inline fun sqrt(a: Float): Float = nativeMath.sqrt(a.toDouble()).toFloat(
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun exp(a: Float): Float = nativeMath.exp(a.toDouble()).toFloat()
public inline fun exp(x: Float): Float = nativeMath.exp(x.toDouble()).toFloat()
/**
* Computes `exp(a) - 1`.
* Computes `exp(x) - 1`.
*
* This function can be implemented to produce more precise result for [a] near zero.
* This function can be implemented to produce more precise result for [x] near zero.
*
* Special cases:
* - `expm1(NaN)` is `NaN`
@@ -771,14 +771,14 @@ public inline fun exp(a: Float): Float = nativeMath.exp(a.toDouble()).toFloat()
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun expm1(a: Float): Float = nativeMath.expm1(a.toDouble()).toFloat()
public inline fun expm1(x: Float): Float = nativeMath.expm1(x.toDouble()).toFloat()
/**
* Computes the logarithm of the value [a] to the given [base].
* Computes the logarithm of the value [x] to the given [base].
*
* Special cases:
* - `log(a, b)` is `NaN` if either `a` or `b` are `NaN`
* - `log(a, b)` is `NaN` when `a < 0` or `b <= 0` or `b == 1.0`
* - `log(x, b)` is `NaN` if either `x` or `b` are `NaN`
* - `log(x, b)` is `NaN` when `x < 0` or `b <= 0` or `b == 1.0`
* - `log(+Inf, +Inf)` is `NaN`
* - `log(+Inf, b)` is `+Inf` for `b > 1` and `-Inf` for `b < 1`
* - `log(0.0, b)` is `-Inf` for `b > 1` and `+Inf` for `b > 1`
@@ -787,10 +787,10 @@ public inline fun expm1(a: Float): Float = nativeMath.expm1(a.toDouble()).toFloa
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun log(a: Float, base: Float): Float = log(a.toDouble(), base.toDouble()).toFloat()
public inline fun log(x: Float, base: Float): Float = log(x.toDouble(), base.toDouble()).toFloat()
/**
* Computes the natural logarithm (base `E`) of the value [a].
* Computes the natural logarithm (base `E`) of the value [x].
*
* Special cases:
* - `ln(NaN)` is `NaN`
@@ -800,30 +800,30 @@ public inline fun log(a: Float, base: Float): Float = log(a.toDouble(), base.toD
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun ln(a: Float): Float = nativeMath.log(a.toDouble()).toFloat()
public inline fun ln(x: Float): Float = nativeMath.log(x.toDouble()).toFloat()
/**
* Computes the common logarithm (base 10) of the value [a].
* Computes the common logarithm (base 10) of the value [x].
*
* @see [ln] function for special cases.
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun log10(a: Float): Float = nativeMath.log10(a.toDouble()).toFloat()
public inline fun log10(x: Float): Float = nativeMath.log10(x.toDouble()).toFloat()
/**
* Computes the binary logarithm (base 2) of the value [a].
* Computes the binary logarithm (base 2) of the value [x].
*
* @see [ln] function for special cases.
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun log2(a: Float): Float = nativeMath.log2(a.toDouble()).toFloat()
public inline fun log2(x: Float): Float = nativeMath.log2(x.toDouble()).toFloat()
/**
* Computes `ln(a + 1)`.
*
* This function can be implemented to produce more precise result for [a] near zero.
* This function can be implemented to produce more precise result for [x] near zero.
*
* Special cases:
* - `ln1p(NaN)` is `NaN`
@@ -836,57 +836,57 @@ public inline fun log2(a: Float): Float = nativeMath.log2(a.toDouble()).toFloat(
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun ln1p(a: Float): Float = nativeMath.log1p(a.toDouble()).toFloat()
public inline fun ln1p(x: Float): Float = nativeMath.log1p(x.toDouble()).toFloat()
/**
* Rounds the given value [a] to an integer towards positive infinity.
* Rounds the given value [x] to an integer towards positive infinity.
* @return the smallest Float value that is greater than the given value [a] and is a mathematical integer.
* @return the smallest Float value that is greater than the given value [x] and is a mathematical integer.
*
* Special cases:
* - `ceil(x)` is `x` where `x` is `NaN` or `+Inf` or `-Inf` or already a mathematical integer.
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun ceil(a: Float): Float = nativeMath.ceil(a.toDouble()).toFloat()
public inline fun ceil(x: Float): Float = nativeMath.ceil(x.toDouble()).toFloat()
/**
* Rounds the given value [a] to an integer towards negative infinity.
* Rounds the given value [x] to an integer towards negative infinity.
* @return the largest Float value that is smaller than the given value [a] and is a mathematical integer.
* @return the largest Float value that is smaller than the given value [x] and is a mathematical integer.
*
* Special cases:
* - `floor(x)` is `x` where `x` is `NaN` or `+Inf` or `-Inf` or already a mathematical integer.
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun floor(a: Float): Float = nativeMath.floor(a.toDouble()).toFloat()
public inline fun floor(x: Float): Float = nativeMath.floor(x.toDouble()).toFloat()
/**
* Rounds the given value [a] to an integer towards zero.
* Rounds the given value [x] to an integer towards zero.
*
* @return the value [a] having its fractional part truncated.
* @return the value [x] having its fractional part truncated.
*
* Special cases:
* - `truncate(x)` is `x` where `x` is `NaN` or `+Inf` or `-Inf` or already a mathematical integer.
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun truncate(a: Float): Float = truncate(a.toDouble()).toFloat()
public inline fun truncate(x: Float): Float = truncate(x.toDouble()).toFloat()
/**
* Rounds the given value [a] towards the closest integer with ties rounded towards even integer.
* Rounds the given value [x] towards the closest integer with ties rounded towards even integer.
*
* Special cases:
* - `round(x)` is `x` where `x` is `NaN` or `+Inf` or `-Inf` or already a mathematical integer.
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun round(a: Float): Float = round(a.toDouble()).toFloat()
public inline fun round(x: Float): Float = round(x.toDouble()).toFloat()
/**
* Returns the absolute value of the given value [a].
* Returns the absolute value of the given value [x].
*
* Special cases:
* - `abs(NaN)` is `NaN`
@@ -895,10 +895,10 @@ public inline fun round(a: Float): Float = round(a.toDouble()).toFloat()
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun abs(a: Float): Float = nativeMath.abs(a.toDouble()).toFloat()
public inline fun abs(x: Float): Float = nativeMath.abs(x.toDouble()).toFloat()
/**
* Returns the sign of the given value [a]:
* Returns the sign of the given value [x]:
* - `-1.0` if the value is negative,
* - zero if the value is zero,
* - `1.0` if the value is positive
@@ -908,7 +908,7 @@ public inline fun abs(a: Float): Float = nativeMath.abs(a.toDouble()).toFloat()
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun sign(a: Float): Float = nativeMath.sign(a.toDouble()).toFloat()
public inline fun sign(x: Float): Float = nativeMath.sign(x.toDouble()).toFloat()
@@ -933,28 +933,28 @@ public inline fun max(a: Float, b: Float): Float = nativeMath.max(a, b)
/**
* Raises this value to the power [other].
* Raises this value to the power [x].
*
* Special cases:
* - `x.pow(0.0)` is `1.0`
* - `x.pow(1.0) == x`
* - `x.pow(NaN)` is `NaN`
* - `b.pow(0.0)` is `1.0`
* - `b.pow(1.0) == b`
* - `b.pow(NaN)` is `NaN`
* - `NaN.pow(x)` is `NaN` for `x != 0.0`
* - `x.pow(Inf)` is `NaN` for `abs(x) == 1.0`
* - `x.pow(y)` is `NaN` for `x < 0` and `y` is finite and not an integer
* - `b.pow(Inf)` is `NaN` for `abs(b) == 1.0`
* - `b.pow(x)` is `NaN` for `b < 0` and `x` is finite and not an integer
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun Float.pow(other: Float): Float = nativeMath.pow(this.toDouble(), other.toDouble()).toFloat()
public inline fun Float.pow(x: Float): Float = nativeMath.pow(this.toDouble(), x.toDouble()).toFloat()
/**
* Raises this value to the integer power [other].
* Raises this value to the integer power [n].
*
* See the other overload of [pow] for details.
*/
@SinceKotlin("1.2")
@InlineOnly
public inline fun Float.pow(other: Int): Float = nativeMath.pow(this.toDouble(), other.toDouble()).toFloat()
public inline fun Float.pow(n: Int): Float = nativeMath.pow(this.toDouble(), n.toDouble()).toFloat()
/**
* Returns the absolute value of this value.
@@ -1029,7 +1029,7 @@ public inline fun Float.roundToLong(): Long = toDouble().roundToLong()
/**
* Returns the absolute value of the given value [a].
* Returns the absolute value of the given value [n].
*
* Special cases:
* - `abs(Int.MIN_VALUE)` is `Int.MIN_VALUE` due to an overflow
@@ -1038,7 +1038,7 @@ public inline fun Float.roundToLong(): Long = toDouble().roundToLong()
*/
// TODO: remove manual 'or' when KT-19290 is fixed
@SinceKotlin("1.2")
public fun abs(a: Int): Int = if (a < 0) (-a or 0) else a
public fun abs(n: Int): Int = if (n < 0) (-n or 0) else n
/**
* Returns the smaller of two values.
@@ -1082,7 +1082,7 @@ public val Int.sign: Int get() = when {
/**
* Returns the absolute value of the given value [a].
* Returns the absolute value of the given value [n].
*
* Special cases:
* - `abs(Long.MIN_VALUE)` is `Long.MIN_VALUE` due to an overflow
@@ -1090,7 +1090,7 @@ public val Int.sign: Int get() = when {
* @see absoluteValue extension property for [Long]
*/
@SinceKotlin("1.2")
public fun abs(a: Long): Long = if (a < 0) -a else a
public fun abs(n: Long): Long = if (n < 0) -n else n
/**
* Returns the smaller of two values.