Implement unsigned arithmetic operations including ulong division and remainder

This commit is contained in:
Ilya Gorbunov
2018-05-04 23:52:37 +03:00
parent e01895fb0a
commit e988ea5a1c
6 changed files with 148 additions and 92 deletions
+22 -22
View File
@@ -52,54 +52,54 @@ public inline class UInt internal constructor(private val data: Int) : Comparabl
public operator fun compareTo(other: ULong): Int = this.toULong().compareTo(other)
/** Adds the other value to this value. */
public operator fun plus(other: UByte): UInt = TODO()
public operator fun plus(other: UByte): UInt = this.plus(other.toUInt())
/** Adds the other value to this value. */
public operator fun plus(other: UShort): UInt = TODO()
public operator fun plus(other: UShort): UInt = this.plus(other.toUInt())
/** Adds the other value to this value. */
public operator fun plus(other: UInt): UInt = TODO()
public operator fun plus(other: UInt): UInt = UInt(this.data.plus(other.data))
/** Adds the other value to this value. */
public operator fun plus(other: ULong): ULong = TODO()
public operator fun plus(other: ULong): ULong = this.toULong().plus(other)
/** Subtracts the other value from this value. */
public operator fun minus(other: UByte): UInt = TODO()
public operator fun minus(other: UByte): UInt = this.minus(other.toUInt())
/** Subtracts the other value from this value. */
public operator fun minus(other: UShort): UInt = TODO()
public operator fun minus(other: UShort): UInt = this.minus(other.toUInt())
/** Subtracts the other value from this value. */
public operator fun minus(other: UInt): UInt = TODO()
public operator fun minus(other: UInt): UInt = UInt(this.data.minus(other.data))
/** Subtracts the other value from this value. */
public operator fun minus(other: ULong): ULong = TODO()
public operator fun minus(other: ULong): ULong = this.toULong().minus(other)
/** Multiplies this value by the other value. */
public operator fun times(other: UByte): UInt = TODO()
public operator fun times(other: UByte): UInt = this.times(other.toUInt())
/** Multiplies this value by the other value. */
public operator fun times(other: UShort): UInt = TODO()
public operator fun times(other: UShort): UInt = this.times(other.toUInt())
/** Multiplies this value by the other value. */
public operator fun times(other: UInt): UInt = TODO()
public operator fun times(other: UInt): UInt = UInt(this.data.times(other.data))
/** Multiplies this value by the other value. */
public operator fun times(other: ULong): ULong = TODO()
public operator fun times(other: ULong): ULong = this.toULong().times(other)
/** Divides this value by the other value. */
public operator fun div(other: UByte): UInt = TODO()
public operator fun div(other: UByte): UInt = this.div(other.toUInt())
/** Divides this value by the other value. */
public operator fun div(other: UShort): UInt = TODO()
public operator fun div(other: UShort): UInt = this.div(other.toUInt())
/** Divides this value by the other value. */
public operator fun div(other: UInt): UInt = TODO()
public operator fun div(other: UInt): UInt = uintDivide(this, other)
/** Divides this value by the other value. */
public operator fun div(other: ULong): ULong = TODO()
public operator fun div(other: ULong): ULong = this.toULong().div(other)
/** Calculates the remainder of dividing this value by the other value. */
public operator fun rem(other: UByte): UInt = TODO()
public operator fun rem(other: UByte): UInt = this.rem(other.toUInt())
/** Calculates the remainder of dividing this value by the other value. */
public operator fun rem(other: UShort): UInt = TODO()
public operator fun rem(other: UShort): UInt = this.rem(other.toUInt())
/** Calculates the remainder of dividing this value by the other value. */
public operator fun rem(other: UInt): UInt = TODO()
public operator fun rem(other: UInt): UInt = uintRemainder(this, other)
/** Calculates the remainder of dividing this value by the other value. */
public operator fun rem(other: ULong): ULong = TODO()
public operator fun rem(other: ULong): ULong = this.toULong().rem(other)
/** Increments this value. */
public operator fun inc(): UInt = TODO()
public operator fun inc(): UInt = UInt(data.inc())
/** Decrements this value. */
public operator fun dec(): UInt = TODO()
public operator fun dec(): UInt = UInt(data.dec())
/** Creates a range from this value to the specified [other] value. */
public operator fun rangeTo(other: UInt): UIntRange = UIntRange(this, other)