Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump minimum Java version to 11 #74

Merged
merged 1 commit into from
Jan 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
kotlin("multiplatform") version "1.8.0"
Expand Down Expand Up @@ -139,8 +140,8 @@ publishing {
}

tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = "1.8"
compilerOptions {
jvmTarget.set(JvmTarget.JVM_11)
}
}

Expand Down
8 changes: 1 addition & 7 deletions src/commonMain/kotlin/ExactMath.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,7 @@ infix fun Long.minusExact(other: Int): Long = this minusExact other.toLong()
* Returns the product of this value and another value, throwing an exception if overflow occurs.
* @throws ArithmeticException if overflow occurs
*/
infix fun Long.timesExact(other: Int): Long = this timesExact other.toLong()

/**
* Returns the product of this value and another value, throwing an exception if overflow occurs.
* @throws ArithmeticException if overflow occurs
*/
infix fun Int.timesExact(other: Long): Long = this.toLong() timesExact other
infix fun Int.timesExact(other: Long): Long = other timesExact this

/**
* Returns the absolute value of a number, throwing an exception if overflow occurs.
Expand Down
6 changes: 6 additions & 0 deletions src/commonMain/kotlin/Platform.kt
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ expect infix fun Long.timesExact(other: Long): Long
*/
expect infix fun Int.timesExact(other: Int): Int

/**
* Returns the product of this value and another value, throwing an exception if overflow occurs.
* @throws ArithmeticException if overflow occurs
*/
expect infix fun Long.timesExact(other: Int): Long

/**
* Returns the negation of this value, throwing an exception if overflow occurs.
* @throws ArithmeticException if overflow occurs
Expand Down
5 changes: 3 additions & 2 deletions src/jvmMain/kotlin/Platform.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ package dev.erikchristensen.javamath2kmp
actual infix fun Long.floorMod(other: Long): Long = Math.floorMod(this, other)
actual infix fun Int.floorMod(other: Int): Int = Math.floorMod(this, other)
actual infix fun Int.floorMod(other: Long): Long = this.toLong() floorMod other
actual infix fun Long.floorMod(other: Int): Int = (this floorMod other.toLong()).toInt()
actual infix fun Long.floorMod(other: Int): Int = Math.floorMod(this, other)

actual infix fun Long.floorDiv(other: Long): Long = Math.floorDiv(this, other)
actual infix fun Int.floorDiv(other: Int): Int = Math.floorDiv(this, other)
actual infix fun Int.floorDiv(other: Long): Long = this.toLong() floorDiv other
actual infix fun Long.floorDiv(other: Int): Long = this floorDiv other.toLong()
actual infix fun Long.floorDiv(other: Int): Long = Math.floorDiv(this, other)

actual infix fun Long.plusExact(other: Long): Long = Math.addExact(this, other)
actual infix fun Int.plusExact(other: Int): Int = Math.addExact(this, other)
Expand All @@ -21,6 +21,7 @@ actual infix fun Int.minusExact(other: Int): Int = Math.subtractExact(this, othe

actual infix fun Long.timesExact(other: Long): Long = Math.multiplyExact(this, other)
actual infix fun Int.timesExact(other: Int): Int = Math.multiplyExact(this, other)
actual infix fun Long.timesExact(other: Int): Long = Math.multiplyExact(this, other)

actual fun Int.negateExact(): Int = Math.negateExact(this)
actual fun Long.negateExact(): Long = Math.negateExact(this)
Expand Down
2 changes: 2 additions & 0 deletions src/nativeJsMain/kotlin/Platform.kt
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ actual infix fun Int.timesExact(other: Int): Int {
return total.toInt()
}

actual infix fun Long.timesExact(other: Int): Long = this timesExact other.toLong()

actual fun Int.negateExact(): Int {
if (this == Int.MIN_VALUE) {
throw ArithmeticException("'$this' can't be negated without overflow")
Expand Down