Minor: split math sources into regions
This commit is contained in:
@@ -20,7 +20,7 @@ public const val PI: Double = 3.141592653589793
|
||||
@SinceKotlin("1.2")
|
||||
public const val E: Double = 2.718281828459045
|
||||
|
||||
// ================ Double Math ========================================
|
||||
// region ================ Double Math ========================================
|
||||
|
||||
/** Computes the sine of the angle [x] given in radians.
|
||||
*
|
||||
@@ -477,10 +477,11 @@ public expect fun Double.roundToInt(): Int
|
||||
@SinceKotlin("1.2")
|
||||
public expect fun Double.roundToLong(): Long
|
||||
|
||||
// endregion
|
||||
|
||||
|
||||
|
||||
// ================ Float Math ========================================
|
||||
// region ================ Float Math ========================================
|
||||
|
||||
/** Computes the sine of the angle [x] given in radians.
|
||||
*
|
||||
@@ -906,6 +907,9 @@ public expect fun Float.roundToInt(): Int
|
||||
public expect fun Float.roundToLong(): Long
|
||||
|
||||
|
||||
// endregion
|
||||
|
||||
// region ================ Integer Math ========================================
|
||||
|
||||
|
||||
/**
|
||||
@@ -997,5 +1001,4 @@ public expect val Long.absoluteValue: Long
|
||||
public expect val Long.sign: Int
|
||||
|
||||
|
||||
|
||||
|
||||
// endregion
|
||||
|
||||
@@ -10,7 +10,7 @@ import kotlin.internal.InlineOnly
|
||||
import kotlin.js.Math as nativeMath
|
||||
|
||||
|
||||
// ================ Double Math ========================================
|
||||
// region ================ Double Math ========================================
|
||||
|
||||
/** Computes the sine of the angle [x] given in radians.
|
||||
*
|
||||
@@ -543,10 +543,11 @@ public actual fun Double.roundToLong(): Long = when {
|
||||
else -> nativeMath.round(this).unsafeCast<Double>().toLong()
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
|
||||
|
||||
// ================ Float Math ========================================
|
||||
// region ================ Float Math ========================================
|
||||
|
||||
/** Computes the sine of the angle [x] given in radians.
|
||||
*
|
||||
@@ -1010,6 +1011,9 @@ public actual inline fun Float.roundToInt(): Int = toDouble().roundToInt()
|
||||
public actual inline fun Float.roundToLong(): Long = toDouble().roundToLong()
|
||||
|
||||
|
||||
// endregion
|
||||
|
||||
// region ================ Integer Math ========================================
|
||||
|
||||
|
||||
/**
|
||||
@@ -1116,3 +1120,4 @@ public actual val Long.sign: Int get() = when {
|
||||
}
|
||||
|
||||
|
||||
// endregion
|
||||
|
||||
@@ -36,7 +36,7 @@ private object Constants {
|
||||
|
||||
}
|
||||
|
||||
// ================ Double Math ========================================
|
||||
// region ================ Double Math ========================================
|
||||
|
||||
/** Computes the sine of the angle [x] given in radians.
|
||||
*
|
||||
@@ -619,8 +619,11 @@ public actual fun Double.roundToInt(): Int = when {
|
||||
public actual fun Double.roundToLong(): Long =
|
||||
if (isNaN()) throw IllegalArgumentException("Cannot round NaN value.") else nativeMath.round(this)
|
||||
|
||||
// endregion
|
||||
|
||||
// ================ Float Math ========================================
|
||||
|
||||
|
||||
// region ================ Float Math ========================================
|
||||
|
||||
/** Computes the sine of the angle [x] given in radians.
|
||||
*
|
||||
@@ -1142,8 +1145,10 @@ public actual fun Float.roundToInt(): Int =
|
||||
public actual fun Float.roundToLong(): Long = toDouble().roundToLong()
|
||||
|
||||
|
||||
// endregion
|
||||
|
||||
// region ================ Integer Math ========================================
|
||||
|
||||
// ================== Integer math functions =====================================
|
||||
|
||||
/**
|
||||
* Returns the absolute value of the given value [n].
|
||||
@@ -1249,3 +1254,5 @@ public actual val Long.sign: Int get() = when {
|
||||
else -> 0
|
||||
}
|
||||
|
||||
|
||||
// endregion
|
||||
|
||||
Reference in New Issue
Block a user