Number

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.3)
abstract class Number

Superclass for all platform classes representing numeric values.

Constructors

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)

<init>

Superclass for all platform classes representing numeric values.

<init>()

Functions

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)

toByte

Returns the value of this number as a Byte, which may involve rounding or truncation.

abstract fun toByte(): Byte
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)

toChar

Returns the Char with the numeric value equal to this number, truncated to 16 bits if appropriate.

abstract fun toChar(): Char
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)

toDouble

Returns the value of this number as a Double, which may involve rounding.

abstract fun toDouble(): Double
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)

toFloat

Returns the value of this number as a Float, which may involve rounding.

abstract fun toFloat(): Float
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)

toInt

Returns the value of this number as an Int, which may involve rounding or truncation.

abstract fun toInt(): Int
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)

toLong

Returns the value of this number as a Long, which may involve rounding or truncation.

abstract fun toLong(): Long
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)

toShort

Returns the value of this number as a Short, which may involve rounding or truncation.

abstract fun toShort(): Short

Extension Functions

Platform and version requirements: Native (1.3)

narrow

fun <R : Number> Number.narrow(): R
Platform and version requirements: Native (1.3)

signExtend

fun <R : Number> Number.signExtend(): R

Inheritors

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)

Byte

Represents a 8-bit signed integer. On the JVM, non-nullable values of this type are represented as values of the primitive type byte.

class Byte : Number, Comparable<Byte>
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)

Double

Represents a double-precision 64-bit IEEE 754 floating point number. On the JVM, non-nullable values of this type are represented as values of the primitive type double.

class Double : Number, Comparable<Double>
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)

Float

Represents a single-precision 32-bit IEEE 754 floating point number. On the JVM, non-nullable values of this type are represented as values of the primitive type float.

class Float : Number, Comparable<Float>
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)

Int

Represents a 32-bit signed integer. On the JVM, non-nullable values of this type are represented as values of the primitive type int.

class Int : Number, Comparable<Int>
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)

Long

Represents a 64-bit signed integer. On the JVM, non-nullable values of this type are represented as values of the primitive type long.

class Long : Number, Comparable<Long>
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)

Short

Represents a 16-bit signed integer. On the JVM, non-nullable values of this type are represented as values of the primitive type short.

class Short : Number, Comparable<Short>

© 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/-number/index.html