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 UByte internal constructor(private val data: Byte) : Compara
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.toUInt().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.toUInt().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 = this.toUInt().plus(other)
/** 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.toUInt().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.toUInt().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 = this.toUInt().minus(other)
/** 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.toUInt().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.toUInt().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 = this.toUInt().times(other)
/** 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.toUInt().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.toUInt().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 = this.toUInt().div(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.toUInt().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.toUInt().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 = this.toUInt().rem(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(): UByte = TODO()
public operator fun inc(): UByte = UByte(data.inc())
/** Decrements this value. */
public operator fun dec(): UByte = TODO()
public operator fun dec(): UByte = UByte(data.dec())
/** Creates a range from this value to the specified [other] value. */
public operator fun rangeTo(other: UByte): UIntRange = UIntRange(this.toUInt(), other.toUInt())