Number

abstract class Number (source)

Superclass for all platform classes representing numeric values.

Constructors

<init>

Number()

Superclass for all platform classes representing numeric values.

Functions

toByte

abstract fun toByte(): Byte

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

toChar

abstract fun toChar(): Char

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

toDouble

abstract fun toDouble(): Double

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

toFloat

abstract fun toFloat(): Float

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

toInt

abstract fun toInt(): Int

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

toLong

abstract fun toLong(): Long

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

toShort

abstract fun toShort(): Short

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

Inherited Functions

equals

open operator fun equals(other: Any?): Boolean

Indicates whether some other object is "equal to" this one. Implementations must fulfil the following requirements:

hashCode

open fun hashCode(): Int

Returns a hash code value for the object. The general contract of hashCode is:

toString

open fun toString(): String

Returns a string representation of the object.

Inheritors

Byte

class Byte : Number, Comparable<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.

Double

class Double : Number, Comparable<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.

Float

class Float : Number, Comparable<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.

Int

class Int : Number, Comparable<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.

Long

class Long : Number, Comparable<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.

Short

class Short : Number, Comparable<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.