W3cubDocs

/Kotlin

toULong

Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
@ExperimentalUnsignedTypes fun Byte.toULong(): ULong

Converts this Byte value to ULong.

If this value is positive, the resulting ULong value represents the same numerical value as this Byte.

The least significant 8 bits of the resulting ULong value are the same as the bits of this Byte value, whereas the most significant 56 bits are filled with the sign bit of this value.

Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
@ExperimentalUnsignedTypes fun Short.toULong(): ULong

Converts this Short value to ULong.

If this value is positive, the resulting ULong value represents the same numerical value as this Short.

The least significant 16 bits of the resulting ULong value are the same as the bits of this Short value, whereas the most significant 48 bits are filled with the sign bit of this value.

Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
@ExperimentalUnsignedTypes fun Int.toULong(): ULong

Converts this Int value to ULong.

If this value is positive, the resulting ULong value represents the same numerical value as this Int.

The least significant 32 bits of the resulting ULong value are the same as the bits of this Int value, whereas the most significant 32 bits are filled with the sign bit of this value.

Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
@ExperimentalUnsignedTypes fun Long.toULong(): ULong

Converts this Long value to ULong.

If this value is positive, the resulting ULong value represents the same numerical value as this Long.

The resulting ULong value has the same binary representation as this Long value.

Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
@ExperimentalUnsignedTypes fun Float.toULong(): ULong

Converts this Float value to ULong.

The fractional part, if any, is rounded down towards zero. Returns zero if this Float value is negative or NaN, ULong.MAX_VALUE if it's bigger than ULong.MAX_VALUE.

Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
@ExperimentalUnsignedTypes fun Double.toULong(): ULong

Converts this Double value to ULong.

The fractional part, if any, is rounded down towards zero. Returns zero if this Double value is negative or NaN, ULong.MAX_VALUE if it's bigger than ULong.MAX_VALUE.

© 2010–2020 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/to-u-long.html