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.

Since Kotlin

1.0

Types

Link copied to clipboard
object Companion
Since Kotlin 1.0

Properties

Link copied to clipboard

Returns the absolute value of this value.

Since Kotlin 1.2

Returns the absolute value of this value.

Since Kotlin 1.2

Returns the absolute value of this value.

Since Kotlin 1.2
Link copied to clipboard
expect val Float.sign: Float

Returns the sign of this value:

Since Kotlin 1.2
actual val Float.sign: Float

Returns the sign of this value:

Since Kotlin 1.2
actual val Float.sign: Float

Returns the sign of this value:

Since Kotlin 1.2
Link copied to clipboard

Returns the ulp of this value.

Since Kotlin 1.2

Functions

Link copied to clipboard
fun Float.coerceAtLeast(minimumValue: Float): Float

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

Since Kotlin 1.0
Link copied to clipboard
fun Float.coerceAtMost(maximumValue: Float): Float

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

Since Kotlin 1.0
Link copied to clipboard
fun Float.coerceIn(minimumValue: Float, maximumValue: Float): Float

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

Since Kotlin 1.0
Link copied to clipboard
operator fun compareTo(other: Byte): Int
operator fun compareTo(other: Double): Int
open operator override fun compareTo(other: Float): Int
operator fun compareTo(other: Int): Int
operator fun compareTo(other: Long): Int
operator fun compareTo(other: Short): Int

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.

Since Kotlin 1.0
Link copied to clipboard
operator fun dec(): Float

Returns this value decremented by one.

Since Kotlin 1.0
Link copied to clipboard
operator fun div(other: Byte): Float
operator fun div(other: Double): Double
operator fun div(other: Float): Float
operator fun div(other: Int): Float
operator fun div(other: Long): Float
operator fun div(other: Short): Float

Divides this value by the other value.

Since Kotlin 1.0
Link copied to clipboard
inline fun Float.IEEErem(divisor: Float): Float

Computes the remainder of division of this value by the divisor value according to the IEEE 754 standard.

Since Kotlin 1.2
Link copied to clipboard
operator fun inc(): Float

Returns this value incremented by one.

Since Kotlin 1.0
Link copied to clipboard
expect fun Float.isFinite(): Boolean
Since Kotlin 1.0
actual fun Float.isFinite(): Boolean

Returns true if the argument is a finite floating-point value; returns false otherwise (for NaN and infinity arguments).

Since Kotlin 1.1
actual inline fun Float.isFinite(): Boolean

Returns true if the argument is a finite floating-point value; returns false otherwise (for NaN and infinity arguments).

Since Kotlin 1.0
Link copied to clipboard
expect fun Float.isInfinite(): Boolean
Since Kotlin 1.0
actual fun Float.isInfinite(): Boolean

Returns true if this value is infinitely large in magnitude.

Since Kotlin 1.1
actual inline fun Float.isInfinite(): Boolean

Returns true if this value is infinitely large in magnitude.

Since Kotlin 1.0
Link copied to clipboard
expect fun Float.isNaN(): Boolean
Since Kotlin 1.0
actual fun Float.isNaN(): Boolean

Returns true if the specified number is a Not-a-Number (NaN) value, false otherwise.

Since Kotlin 1.1
actual inline fun Float.isNaN(): Boolean

Returns true if the specified number is a Not-a-Number (NaN) value, false otherwise.

Since Kotlin 1.0
Link copied to clipboard
operator fun minus(other: Byte): Float
operator fun minus(other: Double): Double
operator fun minus(other: Float): Float
operator fun minus(other: Int): Float
operator fun minus(other: Long): Float
operator fun minus(other: Short): Float

Subtracts the other value from this value.

Since Kotlin 1.0
Link copied to clipboard
inline fun Float.nextDown(): Float

Returns the Float value nearest to this value in direction of negative infinity.

Since Kotlin 1.2
Link copied to clipboard
inline fun Float.nextTowards(to: Float): Float

Returns the Float value nearest to this value in direction from this value towards the value to.

Since Kotlin 1.2
Link copied to clipboard
inline fun Float.nextUp(): Float

Returns the Float value nearest to this value in direction of positive infinity.

Since Kotlin 1.2
Link copied to clipboard
operator fun plus(other: Byte): Float
operator fun plus(other: Double): Double
operator fun plus(other: Float): Float
operator fun plus(other: Int): Float
operator fun plus(other: Long): Float
operator fun plus(other: Short): Float

Adds the other value to this value.

Since Kotlin 1.0
Link copied to clipboard
expect fun Float.pow(x: Float): Float

Raises this value to the power x.

Since Kotlin 1.2
expect fun Float.pow(n: Int): Float

Raises this value to the integer power n.

Since Kotlin 1.2
actual inline fun Float.pow(x: Float): Float

Raises this value to the power x.

Since Kotlin 1.2
actual inline fun Float.pow(n: Int): Float

Raises this value to the integer power n.

Since Kotlin 1.2
actual inline fun Float.pow(x: Float): Float

Raises this value to the power x.

Since Kotlin 1.2
actual inline fun Float.pow(n: Int): Float

Raises this value to the integer power n.

Since Kotlin 1.2
Link copied to clipboard

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

Since Kotlin 1.1
Link copied to clipboard
operator fun rem(other: Byte): Float
operator fun rem(other: Double): Double
operator fun rem(other: Float): Float
operator fun rem(other: Int): Float
operator fun rem(other: Long): Float
operator fun rem(other: Short): Float

Calculates the remainder of truncating division of this value by the other value.

Since Kotlin 1.1
Link copied to clipboard
expect fun Float.roundToInt(): Int

Rounds this Float value to the nearest integer and converts the result to Int. Ties are rounded towards positive infinity.

Since Kotlin 1.2
actual inline fun Float.roundToInt(): Int

Rounds this Float value to the nearest integer and converts the result to Int. Ties are rounded towards positive infinity.

Since Kotlin 1.2
actual fun Float.roundToInt(): Int

Rounds this Float value to the nearest integer and converts the result to Int. Ties are rounded towards positive infinity.

Since Kotlin 1.2
Link copied to clipboard
expect fun Float.roundToLong(): Long

Rounds this Float value to the nearest integer and converts the result to Long. Ties are rounded towards positive infinity.

Since Kotlin 1.2
actual inline fun Float.roundToLong(): Long

Rounds this Float value to the nearest integer and converts the result to Long. Ties are rounded towards positive infinity.

Since Kotlin 1.2
actual fun Float.roundToLong(): Long

Rounds this Float value to the nearest integer and converts the result to Long. Ties are rounded towards positive infinity.

Since Kotlin 1.2
Link copied to clipboard
operator fun times(other: Byte): Float
operator fun times(other: Double): Double
operator fun times(other: Float): Float
operator fun times(other: Int): Float
operator fun times(other: Long): Float
operator fun times(other: Short): Float

Multiplies this value by the other value.

Since Kotlin 1.0
Link copied to clipboard
inline fun Float.toBigDecimal(mathContext: MathContext): BigDecimal

Returns the value of this Float number as a BigDecimal.

Since Kotlin 1.2
Link copied to clipboard
expect fun Float.toBits(): Int

Returns a bit representation of the specified floating-point value as Int according to the IEEE 754 floating-point "single format" bit layout.

Since Kotlin 1.2
actual fun Float.toBits(): Int

Returns a bit representation of the specified floating-point value as Int according to the IEEE 754 floating-point "single format" bit layout.

Since Kotlin 1.2
actual inline fun Float.toBits(): Int

Returns a bit representation of the specified floating-point value as Int according to the IEEE 754 floating-point "single format" bit layout.

Since Kotlin 1.2
Link copied to clipboard
open override fun toByte(): Byte

Converts this Float value to Byte.

Since Kotlin 1.0
Link copied to clipboard
open override fun toChar(): Char

Converts this Float value to Char.

Since Kotlin 1.0
Link copied to clipboard
open override fun toDouble(): Double

Converts this Float value to Double.

Since Kotlin 1.0
Link copied to clipboard
open override fun toFloat(): Float

Returns this value.

Since Kotlin 1.0
Link copied to clipboard
open override fun toInt(): Int

Converts this Float value to Int.

Since Kotlin 1.0
Link copied to clipboard
open override fun toLong(): Long

Converts this Float value to Long.

Since Kotlin 1.0
Link copied to clipboard
expect fun Float.toRawBits(): Int

Returns a bit representation of the specified floating-point value as Int according to the IEEE 754 floating-point "single format" bit layout, preserving NaN values exact layout.

Since Kotlin 1.2
actual fun Float.toRawBits(): Int

Returns a bit representation of the specified floating-point value as Int according to the IEEE 754 floating-point "single format" bit layout, preserving NaN values exact layout.

Since Kotlin 1.2
actual inline fun Float.toRawBits(): Int

Returns a bit representation of the specified floating-point value as Int according to the IEEE 754 floating-point "single format" bit layout, preserving NaN values exact layout.

Since Kotlin 1.2
Link copied to clipboard
open override fun toShort(): Short

Converts this Float value to Short.

Since Kotlin 1.0
Link copied to clipboard
operator fun unaryMinus(): Float

Returns the negative of this value.

Since Kotlin 1.0
Link copied to clipboard
operator fun unaryPlus(): Float

Returns this value.

Since Kotlin 1.0
Link copied to clipboard
expect fun Float.withSign(sign: Float): Float
expect fun Float.withSign(sign: Int): Float

Returns this value with the sign bit same as of the sign value.

Since Kotlin 1.2
actual inline fun Float.withSign(sign: Float): Float
actual inline fun Float.withSign(sign: Int): Float

Returns this value with the sign bit same as of the sign value.

Since Kotlin 1.2
actual inline fun Float.withSign(sign: Float): Float
actual inline fun Float.withSign(sign: Int): Float

Returns this value with the sign bit same as of the sign value.

Since Kotlin 1.2