Add operator 'rem' as extension to BigDecimal
Deprecate 'mod' operator
This commit is contained in:
@@ -76,8 +76,15 @@ public inline operator fun BigDecimal.div(other: BigDecimal) : BigDecimal = this
|
|||||||
* Enables the use of the `%` operator for [BigDecimal] instances.
|
* Enables the use of the `%` operator for [BigDecimal] instances.
|
||||||
*/
|
*/
|
||||||
@kotlin.internal.InlineOnly
|
@kotlin.internal.InlineOnly
|
||||||
|
@Deprecated("Use rem(other) instead", ReplaceWith("rem(other)"), DeprecationLevel.WARNING)
|
||||||
public inline operator fun BigDecimal.mod(other: BigDecimal) : BigDecimal = this.remainder(other)
|
public inline operator fun BigDecimal.mod(other: BigDecimal) : BigDecimal = this.remainder(other)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables the use of the `%` operator for [BigDecimal] instances.
|
||||||
|
*/
|
||||||
|
@kotlin.internal.InlineOnly
|
||||||
|
public inline operator fun BigDecimal.rem(other: BigDecimal) : BigDecimal = this.remainder(other)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enables the use of the unary `-` operator for [BigDecimal] instances.
|
* Enables the use of the unary `-` operator for [BigDecimal] instances.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ class MathTest {
|
|||||||
assertEquals(BigDecimal("2"), BigDecimal("4") / a)
|
assertEquals(BigDecimal("2"), BigDecimal("4") / a)
|
||||||
assertEquals(BigDecimal("-2"), -a)
|
assertEquals(BigDecimal("-2"), -a)
|
||||||
assertEquals(BigDecimal("-2"), -a % b)
|
assertEquals(BigDecimal("-2"), -a % b)
|
||||||
|
assertEquals(BigDecimal("-2"), (-a).mod(b))
|
||||||
|
assertEquals(BigDecimal("-2"), (-a).rem(b))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user