scoop:scoop.core:0.1.0
src/integer_ulong.scoop
Selected production source · src/integer_ulong.scoop
1
/**2
* A 64-bit unsigned integer. Arithmetic wraps modulo 2^64; division by zero throws3
* [ArithmeticException]. Conversions are explicit and preserve the language's fixed-width rules on4
* every target.5
*/6
@Intrinsic("core_ulong")7
public struct ULong :8
Add<ULong, ULong>,9
Sub<ULong, ULong>,10
Mul<ULong, ULong>,11
Div<ULong, ULong>,12
Rem<ULong, ULong>,13
UnaryPlus<ULong>,14
UnaryMinus<ULong>,15
Increment<ULong>,16
Decrement<ULong>,17
Compare<ULong>,18
RangeTo<ULong, ULongRange>,19
RangeUntil<ULong, ULongRange>,20
Equals<ULong>, ToString, Hash {21
/**22
* Rounds the integer directly to IEEE binary32 using round-to-nearest, ties-to-even.23
*/24
@NoGC @Intrinsic("ulong_to_float")25
public fun toFloat(): Float27
/**28
* Rounds the integer directly to IEEE binary64 using round-to-nearest, ties-to-even.29
*/30
@NoGC @Intrinsic("ulong_to_double")31
public fun toDouble(): Double33
/**34
* Compares the mathematical values of two integers of the same type.35
*/36
@NoGC37
@Intrinsic("ulong_equals")38
public override operator fun equals(other: ULong): Boolean41
/**42
* Returns the unchanged integer value.43
*/44
@NoGC45
@Intrinsic("ulong_unary_plus")46
public override operator fun unaryPlus(): ULong48
/**49
* Returns the additive inverse modulo 2^64, including at the representation boundary.50
*/51
@NoGC52
@Intrinsic("ulong_unary_minus")53
public override operator fun unaryMinus(): ULong55
/**56
* Returns the value plus one, wrapping modulo 2^64.57
*/58
@NoGC59
@Intrinsic("ulong_inc")60
public override operator fun inc(): ULong62
/**63
* Returns the value minus one, wrapping modulo 2^64.64
*/65
@NoGC66
@Intrinsic("ulong_dec")67
public override operator fun dec(): ULong69
/**70
* Returns the sum modulo 2^64; overflow does not throw.71
*/72
@NoGC73
@Intrinsic("ulong_add")74
public override operator fun plus(other: ULong): ULong76
/**77
* Returns the difference modulo 2^64; overflow does not throw.78
*/79
@NoGC80
@Intrinsic("ulong_sub")81
public override operator fun minus(other: ULong): ULong83
/**84
* Returns the product modulo 2^64; overflow does not throw.85
*/86
@NoGC87
@Intrinsic("ulong_mul")88
public override operator fun times(other: ULong): ULong90
/**91
* Returns the quotient truncated toward zero. A zero divisor throws [ArithmeticException].92
*/93
@Intrinsic("ulong_div")94
public override operator fun div(other: ULong): ULong96
/**97
* Returns the remainder associated with division truncated toward zero. A zero divisor throws98
* [ArithmeticException].99
*/100
@Intrinsic("ulong_rem")101
public override operator fun rem(other: ULong): ULong103
/**104
* Returns -1, 0, or 1 using unsigned mathematical ordering.105
*/106
@NoGC107
@Intrinsic("ulong_compare_to")108
public override operator fun compareTo(other: ULong): Long110
/**111
* Returns the bitwise intersection of the 64-bit operands.112
*/113
@NoGC114
@Intrinsic("ulong_and")115
public infix fun and(other: ULong): ULong117
/**118
* Returns the bitwise union of the 64-bit operands.119
*/120
@NoGC121
@Intrinsic("ulong_or")122
public infix fun or(other: ULong): ULong124
/**125
* Sets each result bit where the corresponding 64-bit operand bits differ.126
*/127
@NoGC128
@Intrinsic("ulong_xor")129
public infix fun xor(other: ULong): ULong131
/**132
* Flips all 64 bits of the representation.133
*/134
@NoGC135
@Intrinsic("ulong_inv")136
public fun inv(): ULong138
/**139
* Shifts left using the low 6 bits of the Long count; shifted-out bits are discarded.140
*/141
@NoGC142
@Intrinsic("ulong_shl")143
public infix fun shl(count: Long): ULong145
/**146
* Shifts right using the low 6 bits of the Long count, filling with zero bits.147
*/148
@NoGC149
@Intrinsic("ulong_shr")150
public infix fun shr(count: Long): ULong152
/**153
* Converts modulo 2^8 and interprets the result as a 8-bit signed integer. The conversion154
* always succeeds.155
*/156
@NoGC157
@Intrinsic("ulong_to_int8")158
public fun toByte(): Byte160
/**161
* Converts modulo 2^16 and interprets the result as a 16-bit signed integer. The conversion162
* always succeeds.163
*/164
@NoGC165
@Intrinsic("ulong_to_int16")166
public fun toShort(): Short168
/**169
* Converts modulo 2^32 and interprets the result as a 32-bit signed integer. The conversion170
* always succeeds.171
*/172
@NoGC173
@Intrinsic("ulong_to_int")174
public fun toInt(): Int176
/**177
* Converts modulo 2^64 and interprets the result as a 64-bit signed integer. The conversion178
* always succeeds.179
*/180
@NoGC181
@Intrinsic("ulong_to_long")182
public fun toLong(): Long184
/**185
* Converts modulo 2^8 and interprets the result as a 8-bit unsigned integer. The conversion186
* always succeeds.187
*/188
@NoGC189
@Intrinsic("ulong_to_uint8")190
public fun toUByte(): UByte192
/**193
* Converts modulo 2^16 and interprets the result as a 16-bit unsigned integer. The conversion194
* always succeeds.195
*/196
@NoGC197
@Intrinsic("ulong_to_uint16")198
public fun toUShort(): UShort200
/**201
* Converts modulo 2^32 and interprets the result as a 32-bit unsigned integer. The conversion202
* always succeeds.203
*/204
@NoGC205
@Intrinsic("ulong_to_uint")206
public fun toUInt(): UInt208
/**209
* Converts modulo 2^64 and interprets the result as a 64-bit unsigned integer. The conversion210
* always succeeds.211
*/212
@NoGC213
@Intrinsic("ulong_to_ulong")214
public fun toULong(): ULong216
/**217
* Creates an ascending range including both this value and the endpoint.218
*/219
public override operator fun rangeTo(endpoint: ULong): ULongRange =220
ULongRange(this, endpoint, 1uL, false, true)222
/**223
* Creates an ascending range including this value and excluding the endpoint.224
*/225
public override operator fun rangeUntil(endpoint: ULong): ULongRange =226
ULongRange(this, endpoint, 1uL, false, false)228
/**229
* Creates an ascending range with an exclusive endpoint.230
*/231
public infix fun until(endpoint: ULong): ULongRange =232
ULongRange(this, endpoint, 1uL, false, false)234
/**235
* Creates a descending range including both endpoints.236
*/237
public infix fun downTo(endpoint: ULong): ULongRange =238
ULongRange(this, endpoint, 1uL, true, true)240
/**241
* Returns the locale-independent decimal representation of this integer.242
*/243
public override fun toString(): String = coreULongToString(this)245
/**246
* Returns a hash consistent with same-type integer equality.247
*/248
public override fun hash(): Long = coreULongHash(this)250
/**251
* Fixed representation bounds and the scalar encoding, decoding, and inspection protocols.252
*/253
public companion object : ValueEncoder<ULong>, ValueDecoder<ULong>, ValueInspector<ULong> {254
/**255
* Exposes the integer as a scalar value observation without reference identity.256
*/257
public override fun inspect(value: ULong): ValueView =258
ValueObservation(typeInfo<ULong>().type, None, { ValueShape.Scalar(ScalarValue.Unsigned(value)) })260
/**261
* The smallest representable 64-bit unsigned integer.262
*/263
public const val MIN_VALUE: ULong = 0uL264
/**265
* The largest representable 64-bit unsigned integer.266
*/267
public const val MAX_VALUE: ULong = 18446744073709551615uL269
/**270
* Writes the integer through the encoder's single-value container.271
*/272
public override fun encode(value: ULong, encoder: Encoder): Unit =273
encoder.singleValue().writeULong(value.toULong())275
/**276
* Decodes an integer and rejects values outside the 64-bit unsigned range with277
* [DecodingException].278
*/279
public override fun decode(decoder: Decoder): ULong =280
decoder.singleValue().readULong()281
}282
}