Might there be a better way to multiply an integer...
# announcements
d
Might there be a better way to multiply an integer with a float and getting a result of Integer? (paddingTop is Int, factor is Float)
Copy code
paddingTop = (paddingTop * factor).toInt()
Maybe an extension function but this seems odd:
Copy code
private fun Int.fMul(factor: Float) = (this * factor).toInt()
a
I've been thinking about it. It's just a minor modification from your example, but maybe make your extension function an infix function? So using the function looks more like using an operator:
Copy code
fun main() {
    print(2 fMul 3.2f)
}

private infix fun Int.fMul(other: Float) = (this * other).toInt()