org.hnau.base.extensions.number.DoubleExtensions.kt Maven / Gradle / Ivy
package org.hnau.base.extensions.number
import org.hnau.base.extensions.*
fun Double.asPercentageInter(
from: Number, to: Number
) = from.toDouble().let { fromDouble ->
fromDouble + (to.toDouble() - fromDouble) * this
}
inline fun Double.ifPositive(action: (Double) -> R) = ifLargeThan(0.0, action)
inline fun Double.ifNegative(action: (Double) -> R) = ifLessThan(0.0, action)
inline fun Double.ifNotNegative(action: (Double) -> R) = ifNotLessThan(0.0, action)
inline fun Double.ifNotPositive(action: (Double) -> R) = ifNotLargeThan(0.0, action)
fun Double.takeIfPositive() = ifPositive(::it)
fun Double.takeIfNegative() = ifNegative(::it)
fun Double.takeIfNotNegative() = ifNotNegative(::it)
fun Double.takeIfNotPositive() = ifNotPositive(::it)
© 2015 - 2025 Weber Informatics LLC | Privacy Policy