Float
class Float : Number, Comparable<Float>For Common, JVM, JS
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.
For Native
Represents a single-precision 32-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(): Floatdiv
Divides this value by the other value.
operator fun div(other: Byte): Floatoperator fun div(other: Short): Floatoperator fun div(other: Int): Floatoperator fun div(other: Long): Floatoperator fun div(other: Float): Floatoperator fun div(other: Double): Doubleequals
fun equals(other: Float): 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(): Floatminus
Subtracts the other value from this value.
operator fun minus(other: Byte): Floatoperator fun minus(other: Short): Floatoperator fun minus(other: Int): Floatoperator fun minus(other: Long): Floatoperator fun minus(other: Float): Floatoperator fun minus(other: Double): Doublemod
Calculates the remainder of dividing this value by the other value.
operator fun mod(other: Byte): Floatoperator fun mod(other: Short): Floatoperator fun mod(other: Int): Floatoperator fun mod(other: Long): Floatoperator fun mod(other: Float): Floatoperator fun mod(other: Double): Doubleplus
Adds the other value to this value.
operator fun plus(other: Byte): Floatoperator fun plus(other: Short): Floatoperator fun plus(other: Int): Floatoperator fun plus(other: Long): Floatoperator fun plus(other: Float): Floatoperator fun plus(other: Double): Doublerem
Calculates the remainder of dividing this value by the other value.
operator fun rem(other: Byte): Floatoperator fun rem(other: Short): Floatoperator fun rem(other: Int): Floatoperator fun rem(other: Long): Floatoperator fun rem(other: Float): Floatoperator fun rem(other: Double): Doubletimes
Multiplies this value by the other value.
operator fun times(other: Byte): Floatoperator fun times(other: Short): Floatoperator fun times(other: Int): Floatoperator fun times(other: Long): Floatoperator fun times(other: Float): Floatoperator fun times(other: Double): DoubletoFloat
Returns this value.
fun toFloat(): FloattoString
Returns a string representation of the object.
fun toString(): StringunaryMinus
Returns the negative of this value.
operator fun unaryMinus(): FloatunaryPlus
Returns this value.
operator fun unaryPlus(): FloatCompanion Object Properties
MAX_VALUE
A constant holding the largest positive finite value of Float.
val MAX_VALUE: Floatconst val MAX_VALUE: FloatMIN_VALUE
A constant holding the smallest positive nonzero value of Float.
val MIN_VALUE: Floatconst val MIN_VALUE: FloatNaN
A constant holding the "not a number" value of Float.
val NaN: FloatNEGATIVE_INFINITY
A constant holding the negative infinity value of Float.
val NEGATIVE_INFINITY: FloatPOSITIVE_INFINITY
A constant holding the positive infinity value of Float.
val POSITIVE_INFINITY: FloatExtension Functions
coerceAtLeast
Ensures that this value is not less than the specified minimumValue.
fun Float.coerceAtLeast(minimumValue: Float): Floatfun <T : Comparable<T>> T.coerceAtLeast(minimumValue: T): TcoerceAtMost
Ensures that this value is not greater than the specified maximumValue.
fun Float.coerceAtMost(maximumValue: Float): Floatfun <T : Comparable<T>> T.coerceAtMost(maximumValue: T): TcoerceIn
Ensures that this value lies in the specified range minimumValue..maximumValue.
fun Float.coerceIn(
minimumValue: Float,
maximumValue: Float
): Floatfun <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 Float value to the specified that value.
operator fun Float.rangeTo(
that: Float
): ClosedFloatingPointRange<Float>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 Float number as a BigDecimal.
fun Float.toBigDecimal(): BigDecimalfun Float.toBigDecimal(mathContext: MathContext): BigDecimal