round

fun <T : Units> round(measure: Measure<T>): Measure<T>(source)

Rounds the measure to the closest integer, retaining its units.


fun <T : Units> round(measure: Measure<T>, toNearest: Measure<T>): Measure<T>(source)

Returns a Measure that is rounded to he closest multiple of toNearest, and has the the units of toNearest.

val length = 25 * inches

round(length, toNearest = 1 * feet ) // 2.0 feet
round(length, toNearest = 0.1 * meters) // 0.6 m

See also

extension property of Measure