Implement unsigned comparisons

This commit is contained in:
Ilya Gorbunov
2018-05-04 07:39:39 +03:00
parent e4216099b3
commit 89e4fdfa9c
6 changed files with 32 additions and 17 deletions
+4 -4
View File
@@ -28,28 +28,28 @@ public inline class UInt internal constructor(private val data: Int) : Comparabl
* Returns zero if this value is equal to the specified other value, a negative number if it's less than other,
* or a positive number if it's greater than other.
*/
public operator fun compareTo(other: UByte): Int = TODO()
public operator fun compareTo(other: UByte): Int = this.compareTo(other.toUInt())
/**
* Compares this value with the specified value for order.
* Returns zero if this value is equal to the specified other value, a negative number if it's less than other,
* or a positive number if it's greater than other.
*/
public operator fun compareTo(other: UShort): Int = TODO()
public operator fun compareTo(other: UShort): Int = this.compareTo(other.toUInt())
/**
* Compares this value with the specified value for order.
* Returns zero if this value is equal to the specified other value, a negative number if it's less than other,
* or a positive number if it's greater than other.
*/
public override operator fun compareTo(other: UInt): Int = TODO()
public override operator fun compareTo(other: UInt): Int = uintCompare(this.data, other.data)
/**
* Compares this value with the specified value for order.
* Returns zero if this value is equal to the specified other value, a negative number if it's less than other,
* or a positive number if it's greater than other.
*/
public operator fun compareTo(other: ULong): Int = TODO()
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()