@@ -645,11 +645,23 @@ public sealed class NumericalID : ID() {
645
645
*/
646
646
public abstract fun toLong (): Long
647
647
648
+ /* *
649
+ * 将数字值转化为 [ULong]。
650
+ */
651
+ public open fun toULong (): ULong =
652
+ toLong().toULong()
653
+
648
654
/* *
649
655
* 将数字值转化为 [Int]。类似于 [Number.toInt]
650
656
*/
651
657
public abstract fun toInt (): Int
652
658
659
+ /* *
660
+ * 将数字值转化为 [UInt]。
661
+ */
662
+ public open fun toUInt (): UInt =
663
+ toInt().toUInt()
664
+
653
665
/* *
654
666
* 将数字值转化为 [Short]。类似于 [Number.toShort]
655
667
*/
@@ -683,7 +695,7 @@ public sealed class NumericalID : ID() {
683
695
* - [IntID] 32位有符号整型
684
696
* - [LongID] 64位有符号整型
685
697
*
686
- * 如果想要作为ID的数字已经超过64位有符号 ([LongID]) 锁能表示的最大数字 ,
698
+ * 如果想要作为ID的数字已经超过64位有符号 ([LongID]) 所能表示的最大数字 ,
687
699
* 那么建议使用其他类型来表示,例如 [ULongID] 或 [StringID]
688
700
*
689
701
*
@@ -698,7 +710,7 @@ public sealed class SignedNumericID : NumericalID()
698
710
* - [UIntID] 32位无符号整型
699
711
* - [ULongID] 64位无符号整型
700
712
*
701
- * 如果想要作为ID的数字已经超过64位无符号 ([ULongID]) 锁能表示的最大数字 ,
713
+ * 如果想要作为ID的数字已经超过64位无符号 ([ULongID]) 所能表示的最大数字 ,
702
714
* 那么建议使用其他类型来表示,例如 [StringID]
703
715
*
704
716
* 在 Java 中对无符号数字的操作需要有些注意的地方。
@@ -782,6 +794,7 @@ public class UIntID private constructor(@get:JvmName("getValue") public val valu
782
794
override fun toFloat (): Float = value.toFloat()
783
795
override fun toLong (): Long = value.toLong()
784
796
override fun toInt (): Int = value.toInt()
797
+ override fun toUInt (): UInt = value
785
798
override fun toShort (): Short = value.toShort()
786
799
override fun toByte (): Byte = value.toByte()
787
800
override fun toString (): String = value.toString()
@@ -895,6 +908,7 @@ public class ULongID private constructor(@get:JvmName("getValue") public val val
895
908
override fun toDouble (): Double = value.toDouble()
896
909
override fun toFloat (): Float = value.toFloat()
897
910
override fun toLong (): Long = value.toLong()
911
+ override fun toULong (): ULong = value
898
912
override fun toInt (): Int = value.toInt()
899
913
override fun toShort (): Short = value.toShort()
900
914
override fun toByte (): Byte = value.toByte()
0 commit comments