Skip to content

Commit

Permalink
add sign getter to value class
Browse files Browse the repository at this point in the history
  • Loading branch information
sswadkar committed Jan 8, 2023
1 parent 2a967ea commit d4fdfd4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/kotlin/org/team4099/lib/units/Value.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package org.team4099.lib.units

import kotlin.math.absoluteValue
import kotlin.math.sign

@JvmInline
value class Value<T : UnitKey>(val value: Double) : Comparable<Value<T>> {
val absoluteValue: Value<T>
get() = Value(value.absoluteValue)

val sign: Double
get() = sign(value)

operator fun plus(o: Value<T>): Value<T> = Value(value + o.value)
operator fun minus(o: Value<T>): Value<T> = Value(value - o.value)

Expand Down

0 comments on commit d4fdfd4

Please sign in to comment.