floor()

py9792289087's avatar
Published Oct 14, 2023
Contribute to Docs

The floor() function takes a value and returns the nearest integer that is lower than or equal to the value given.

The result returns a value type of float.

Syntax

import kotlin.math.*
floor(x)

Where x is the number of type double to be rounded down to the nearest integer.

Example

The following example demonstrates a basic implementation of the floor() method.

import kotlin.math.*
println(floor(3.4))

This will output:

3.0

The result will be a float value of 3 as the function rounds 3.4 down to 3.

All contributors

Contribute to Docs

Learn Kotlin on Codecademy