Double
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
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): Intoperator fun compareTo(other: Short): Intoperator fun compareTo(other: Int): Intoperator fun compareTo(other: Long): Intoperator fun compareTo(other: Float): Intoperator fun compareTo(other: Double): Intdec
Decrements this value.
operator fun dec(): Doublediv
Divides this value by the other value.
operator fun div(other: Byte): Doubleoperator fun div(other: Short): Doubleoperator fun div(other: Int): Doubleoperator fun div(other: Long): Doubleoperator fun div(other: Float): Doubleoperator fun div(other: Double): Doubleequals
fun equals(other: Double): BooleanIndicates whether some other object is "equal to" this one. Implementations must fulfil the following requirements:
fun equals(other: Any?): BooleanhashCode
Returns a hash code value for the object. The general contract of hashCode is:
fun hashCode(): Intinc
Increments this value.
operator fun inc(): Doubleminus
Subtracts the other value from this value.
operator fun minus(other: Byte): Doubleoperator fun minus(other: Short): Doubleoperator fun minus(other: Int): Doubleoperator fun minus(other: Long): Doubleoperator fun minus(other: Float): Doubleoperator fun minus(other: Double): Doublemod
Calculates the remainder of dividing this value by the other value.
operator fun mod(other: Byte): Doubleoperator fun mod(other: Short): Doubleoperator fun mod(other: Int): Doubleoperator fun mod(other: Long): Doubleoperator fun mod(other: Float): Doubleoperator fun mod(other: Double): Doubleplus
Adds the other value to this value.
operator fun plus(other: Byte): Doubleoperator fun plus(other: Short): Doubleoperator fun plus(other: Int): Doubleoperator fun plus(other: Long): Doubleoperator fun plus(other: Float): Doubleoperator fun plus(other: Double): Doublerem
Calculates the remainder of dividing this value by the other value.
operator fun rem(other: Byte): Doubleoperator fun rem(other: Short): Doubleoperator fun rem(other: Int): Doubleoperator fun rem(other: Long): Doubleoperator fun rem(other: Float): Doubleoperator fun rem(other: Double): Doubletimes
Multiplies this value by the other value.
operator fun times(other: Byte): Doubleoperator fun times(other: Short): Doubleoperator fun times(other: Int): Doubleoperator fun times(other: Long): Doubleoperator fun times(other: Float): Doubleoperator fun times(other: Double): DoubletoDouble
Returns this value.
fun toDouble(): DoubletoString
Returns a string representation of the object.
fun toString(): StringunaryMinus
Returns the negative of this value.
operator fun unaryMinus(): DoubleunaryPlus
Returns this value.
operator fun unaryPlus(): DoubleCompanion Object Properties
MAX_VALUE
A constant holding the largest positive finite value of Double.
val MAX_VALUE: Doubleconst val MAX_VALUE: DoubleMIN_VALUE
A constant holding the smallest positive nonzero value of Double.
val MIN_VALUE: Doubleconst val MIN_VALUE: DoubleNaN
A constant holding the "not a number" value of Double.
val NaN: DoubleNEGATIVE_INFINITY
A constant holding the negative infinity value of Double.
val NEGATIVE_INFINITY: DoublePOSITIVE_INFINITY
A constant holding the positive infinity value of Double.
val POSITIVE_INFINITY: DoubleExtension Properties
Extension Functions
coerceAtLeast
Ensures that this value is not less than the specified minimumValue.
fun Double.coerceAtLeast(minimumValue: Double): Doublefun <T : Comparable<T>> T.coerceAtLeast(minimumValue: T): TcoerceAtMost
Ensures that this value is not greater than the specified maximumValue.
fun Double.coerceAtMost(maximumValue: Double): Doublefun <T : Comparable<T>> T.coerceAtMost(maximumValue: T): TcoerceIn
Ensures that this value lies in the specified range minimumValue..maximumValue.
fun Double.coerceIn(
minimumValue: Double,
maximumValue: Double
): Doublefun <T : Comparable<T>> T.coerceIn(
minimumValue: T?,
maximumValue: T?
): TEnsures that this value lies in the specified range.
fun <T : Comparable<T>> T.coerceIn(
range: ClosedFloatingPointRange<T>
): Tfun <T : Comparable<T>> T.coerceIn(range: ClosedRange<T>): TrangeTo
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>toBigDecimal
Returns the value of this Double number as a BigDecimal.
fun Double.toBigDecimal(): BigDecimalfun Double.toBigDecimal(mathContext: MathContext): BigDecimaltoDuration
Returns a Duration equal to this Double number of the specified unit.
fun Double.toDuration(unit: DurationUnit): Duration