Kotlin – Convert Float to String

Convert float to string in Kotlin

To convert a given float value to a string type value in Kotlin, you can use Float.toString() function.

Call toString() function on the given float value, say floatValue.

floatValue.toString()

The function returns a string value created from the content in the given float value.

Examples

Convert the float 3.14f to string value

In the following program, we take a float value in floatValue variable. We convert this float value to a string value and print it to output.

Kotlin Program

fun main() {
    val floatValue = 3.14f
    val str = floatValue.toString()
    println(str)
}

Output

3.14