toBigInteger
Returns the value of this Int number as a BigInteger.
Since Kotlin
1.2Samples
fun main() {
//sampleStart
println(42.toBigInteger()) // 42
println(Int.MAX_VALUE.toBigInteger()) // 2147483647
println(Int.MIN_VALUE.toBigInteger()) // -2147483648
// BigInteger can hold values beyond Int range
println(Int.MAX_VALUE.toBigInteger() * 10.toBigInteger()) // 21474836470
//sampleEnd
}Returns the value of this Long number as a BigInteger.
Since Kotlin
1.2Samples
fun main() {
//sampleStart
println(42L.toBigInteger()) // 42
println(Long.MAX_VALUE.toBigInteger()) // 9223372036854775807
println(Long.MIN_VALUE.toBigInteger()) // -9223372036854775808
// BigInteger can hold values beyond Long range
println(Long.MAX_VALUE.toBigInteger() * 10.toBigInteger()) // 92233720368547758070
//sampleEnd
}Returns the value of this UInt number as a BigInteger.
Since Kotlin
2.4Samples
fun main() {
//sampleStart
println(42u.toBigInteger()) // 42
println(UInt.MAX_VALUE.toBigInteger()) // 4294967295
// BigInteger can hold values beyond UInt range
println(UInt.MAX_VALUE.toBigInteger() * 10.toBigInteger()) // 42949672950
//sampleEnd
}Returns the value of this ULong number as a BigInteger.
Since Kotlin
2.4Samples
fun main() {
//sampleStart
println(42uL.toBigInteger()) // 42
println(ULong.MAX_VALUE.toBigInteger()) // 18446744073709551615
// BigInteger can hold values beyond ULong range
println(ULong.MAX_VALUE.toBigInteger() * 10.toBigInteger()) // 184467440737095516150
//sampleEnd
}