kotlin Number to Long

fun main() {
    val number: Number = 42
    val longValue: Long = number.toLong()

    println("Original number: $number")
    println("Converted to Long: $longValue")
}

Explanation:

  1. Declare a variable number of type Number and assign it the value 42.
  2. Declare a variable longValue of type Long and assign it the result of converting the number to a Long using the toLong() method.
  3. Print the original number and the converted Long value using println().