Double

Common
JVM
JS
Native
1.0
class Double : Number, Comparable<Double>
For Common, JVM, JS

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.

For Native

Represents a double-precision 64-bit IEEE 754 floating point number.

Functions

Common
JVM
JS
Native
1.0

compareTo

Compares this value with the specified value for order. Returns zero if this value is equal to the specified other value, a negative number if it's less than other, or a positive number if it's greater than other.

operator fun compareTo(other: Byte): Int
operator fun compareTo(other: Short): Int
operator fun compareTo(other: Int): Int
operator fun compareTo(other: Long): Int
operator fun compareTo(other: Float): Int
operator fun compareTo(other: Double): Int
Common
JVM
JS
Native
1.0

dec

Decrements this value.

operator fun dec(): Double
Common
JVM
JS
Native
1.0

div

Divides this value by the other value.

operator fun div(other: Byte): Double
operator fun div(other: Short): Double
operator fun div(other: Int): Double
operator fun div(other: Long): Double
operator fun div(other: Float): Double
operator fun div(other: Double): Double
Native
1.3

equals

fun equals(other: Double): Boolean

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

fun equals(other: Any?): Boolean
Native
1.3

hashCode

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

fun hashCode(): Int
Common
JVM
JS
Native
1.0

inc

Increments this value.

operator fun inc(): Double
Common
JVM
JS
Native
1.0

minus

Subtracts the other value from this value.

operator fun minus(other: Byte): Double
operator fun minus(other: Short): Double
operator fun minus(other: Int): Double
operator fun minus(other: Long): Double
operator fun minus(other: Float): Double
operator fun minus(other: Double): Double
Common
JVM
JS
Native
1.0

mod

Calculates the remainder of dividing this value by the other value.

operator fun mod(other: Byte): Double
operator fun mod(other: Short): Double
operator fun mod(other: Int): Double
operator fun mod(other: Long): Double
operator fun mod(other: Float): Double
operator fun mod(other: Double): Double
Common
JVM
JS
Native
1.0

plus

Adds the other value to this value.

operator fun plus(other: Byte): Double
operator fun plus(other: Short): Double
operator fun plus(other: Int): Double
operator fun plus(other: Long): Double
operator fun plus(other: Float): Double
operator fun plus(other: Double): Double
Common
JVM
JS
Native
1.1

rem

Calculates the remainder of dividing this value by the other value.

operator fun rem(other: Byte): Double
operator fun rem(other: Short): Double
operator fun rem(other: Int): Double
operator fun rem(other: Long): Double
operator fun rem(other: Float): Double
operator fun rem(other: Double): Double
Common
JVM
JS
Native
1.0

times

Multiplies this value by the other value.

operator fun times(other: Byte): Double
operator fun times(other: Short): Double
operator fun times(other: Int): Double
operator fun times(other: Long): Double
operator fun times(other: Float): Double
operator fun times(other: Double): Double
Common
JVM
JS
Native
1.0

toByte

Converts this Double value to Byte.

fun toByte(): Byte
Common
JVM
JS
Native
1.0

toChar

Converts this Double value to Char.

fun toChar(): Char
Common
JVM
JS
Native
1.0

toDouble

Returns this value.

fun toDouble(): Double
Common
JVM
JS
Native
1.0

toFloat

Converts this Double value to Float.

fun toFloat(): Float
Common
JVM
JS
Native
1.0

toInt

Converts this Double value to Int.

fun toInt(): Int
Common
JVM
JS
Native
1.0

toLong

Converts this Double value to Long.

fun toLong(): Long
Common
JVM
JS
Native
1.0

toShort

Converts this Double value to Short.

fun toShort(): Short
Native
1.3

toString

Returns a string representation of the object.

fun toString(): String
Common
JVM
JS
Native
1.0

unaryMinus

Returns the negative of this value.

operator fun unaryMinus(): Double
Common
JVM
JS
Native
1.0

unaryPlus

Returns this value.

operator fun unaryPlus(): Double

Companion Object Properties

MAX_VALUE

A constant holding the largest positive finite value of Double.

Common
JVM
JS
1.0
val MAX_VALUE: Double
Native
1.3
const val MAX_VALUE: Double

MIN_VALUE

A constant holding the smallest positive nonzero value of Double.

Common
JVM
JS
1.0
val MIN_VALUE: Double
Native
1.3
const val MIN_VALUE: Double
Common
JVM
JS
Native
1.0

NaN

A constant holding the "not a number" value of Double.

val NaN: Double
Common
JVM
JS
Native
1.0

NEGATIVE_INFINITY

A constant holding the negative infinity value of Double.

val NEGATIVE_INFINITY: Double
Common
JVM
JS
Native
1.0

POSITIVE_INFINITY

A constant holding the positive infinity value of Double.

val POSITIVE_INFINITY: Double

Extension Properties

Common
JVM
JS
Native
1.3

days

Returns a Duration equal to this Double number of days.

val Double.days: Duration
Common
JVM
JS
Native
1.3

hours

Returns a Duration equal to this Double number of hours.

val Double.hours: Duration
Common
JVM
JS
Native
1.3

microseconds

Returns a Duration equal to this Double number of microseconds.

val Double.microseconds: Duration
Common
JVM
JS
Native
1.3

milliseconds

Returns a Duration equal to this Double number of milliseconds.

val Double.milliseconds: Duration
Common
JVM
JS
Native
1.3

minutes

Returns a Duration equal to this Double number of minutes.

val Double.minutes: Duration
Common
JVM
JS
Native
1.3

nanoseconds

Returns a Duration equal to this Double number of nanoseconds.

val Double.nanoseconds: Duration
Common
JVM
JS
Native
1.3

seconds

Returns a Duration equal to this Double number of seconds.

val Double.seconds: Duration

Extension Functions

Common
JVM
JS
Native
1.0

coerceAtLeast

Ensures that this value is not less than the specified minimumValue.

fun Double.coerceAtLeast(minimumValue: Double): Double
fun <T : Comparable<T>> T.coerceAtLeast(minimumValue: T): T
Common
JVM
JS
Native
1.0

coerceAtMost

Ensures that this value is not greater than the specified maximumValue.

fun Double.coerceAtMost(maximumValue: Double): Double
fun <T : Comparable<T>> T.coerceAtMost(maximumValue: T): T
Common
JVM
JS
Native
1.0

coerceIn

Ensures that this value lies in the specified range minimumValue..maximumValue.

fun Double.coerceIn(
    minimumValue: Double,
    maximumValue: Double
): Double
fun <T : Comparable<T>> T.coerceIn(
    minimumValue: T?,
    maximumValue: T?
): T

Ensures that this value lies in the specified range.

fun <T : Comparable<T>> T.coerceIn(
    range: ClosedFloatingPointRange<T>
): T
fun <T : Comparable<T>> T.coerceIn(range: ClosedRange<T>): T
Native
1.3

narrow

fun <R : Number> Number.narrow(): R
Common
JVM
JS
Native
1.0

rangeTo

Creates a range from this Double value to the specified that value.

operator fun Double.rangeTo(
    that: Double
): ClosedFloatingPointRange<Double>

Creates a range from this Comparable value to the specified that value.

operator fun <T : Comparable<T>> T.rangeTo(
    that: T
): ClosedRange<T>
Native
1.3

signExtend

fun <R : Number> Number.signExtend(): R
Common
JVM
JS
Native
1.3

times

Returns a duration whose value is the specified duration value multiplied by this number.

operator fun Double.times(duration: Duration): Duration
JVM
1.2

toBigDecimal

Returns the value of this Double number as a BigDecimal.

fun Double.toBigDecimal(): BigDecimal
fun Double.toBigDecimal(mathContext: MathContext): BigDecimal
Common
JVM
JS
Native
1.3

toDuration

Returns a Duration equal to this Double number of the specified unit.

fun Double.toDuration(unit: DurationUnit): Duration
Common
JVM
JS
Native
1.3

toUInt

Converts this Double value to UInt.

fun Double.toUInt(): UInt
Common
JVM
JS
Native
1.3

toULong

Converts this Double value to ULong.

fun Double.toULong(): ULong