roundedValue

Converts receiving Distance to given unit and rounds to exact decimals. Returns are either long or double, depending on whether the resulting value has a fractional component.


fun Speed.roundedValue(unit: SpeedUnit, decimals: Int): Number

Converts the current Speed to the specified unit and rounds it to the specified number of decimals.

The return value is either a Long or a Double, depending on whether the resulting value contains a fractional component:

  • If the value has no fractional component after rounding, a Long is returned.

  • Otherwise, a Double is returned.

Return

The rounded speed value as a Number, either Long or Double.

Parameters

unit

The SpeedUnit to which the speed will be converted.

decimals

The number of decimal places to round the value to.