Dev #127

Merged
altavir merged 214 commits from dev into master 2020-08-11 08:33:21 +03:00
Showing only changes of commit 1614eef452 - Show all commits

View File

@ -7,13 +7,14 @@ import java.math.MathContext
/** /**
* A field wrapper for Java [BigInteger] * A field wrapper for Java [BigInteger]
*/ */
object JBigIntegerRing : Ring<BigInteger>, PowerOperations<BigInteger> { object JBigIntegerField : Field<BigInteger>, PowerOperations<BigInteger> {
override val zero: BigInteger override val zero: BigInteger
get() = BigInteger.ZERO get() = BigInteger.ZERO
override val one: BigInteger override val one: BigInteger
get() = BigInteger.ONE get() = BigInteger.ONE
override fun divide(a: BigInteger, b: BigInteger): BigInteger = a.div(b)
override fun add(a: BigInteger, b: BigInteger): BigInteger = a.add(b) override fun add(a: BigInteger, b: BigInteger): BigInteger = a.add(b)
override fun BigInteger.minus(b: BigInteger): BigInteger = this.subtract(b) override fun BigInteger.minus(b: BigInteger): BigInteger = this.subtract(b)
override fun multiply(a: BigInteger, k: Number): BigInteger = a.multiply(k.toInt().toBigInteger()) override fun multiply(a: BigInteger, k: Number): BigInteger = a.multiply(k.toInt().toBigInteger())
@ -54,7 +55,3 @@ abstract class JBigDecimalFieldBase internal constructor(val mathContext: MathCo
class JBigDecimalField(mathContext: MathContext = MathContext.DECIMAL64) : JBigDecimalFieldBase(mathContext) { class JBigDecimalField(mathContext: MathContext = MathContext.DECIMAL64) : JBigDecimalFieldBase(mathContext) {
companion object : JBigDecimalFieldBase() companion object : JBigDecimalFieldBase()
} }
fun main() {
JBigDecimalField { one pow 2 }
}