Skip to content

Commit

Permalink
Merge pull request #5 from LartyHD/patch-3
Browse files Browse the repository at this point in the history
update Power part #3
  • Loading branch information
MarcinMoskala committed Jan 12, 2019
2 parents 2209025 + 31fc0e0 commit c65ae6c
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/main/java/com/marcinmoskala/math/Power.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,21 @@
@file:JvmMultifileClass
package com.marcinmoskala.math

fun Int.pow(power: Int): Int = Math.pow(this.toDouble(), power.toDouble()).toInt()
import java.math.BigDecimal
import java.math.BigInteger

infix fun Number.pow(power: Number): Double = Math.pow(this.toDouble(), power.toDouble())

infix fun BigInteger.pow(power: BigInteger): BigInteger = pow(power).toBigInteger()

infix fun BigDecimal.pow(power: BigDecimal): BigDecimal = pow(power).toBigDecimal()

infix fun Double.pow(power: Double): Double = pow(power)

infix fun Long.pow(power: Long): Long = pow(power).toLong()

infix fun Int.pow(power: Int): Int = pow(power).toInt()

infix fun Short.pow(power: Short): Short = pow(power).toShort()

infix fun Byte.pow(power: Byte): Byte = pow(power).toByte()

0 comments on commit c65ae6c

Please sign in to comment.