Package com.tomtom.tools.android.core.math

Functions

Link copied to clipboard
fun <T : Number> getFraction(part: T, whole: T): Double

Helper function to convert a part amount of a whole into a fraction. The returned range is [0.0, 1.0], making it suitable for UI elements (such as progress bars) requiring such value intervals.

Link copied to clipboard
fun roundToNearest(value: Double, step: Double): Double

A helper function to round double value given a step size. For example rounding 1.45 with step 0.1 would round up and return 1.5.

fun roundToNearest(value: Int, step: Int): Int

A helper function to round integer value given a step size. For example rounding 40 with step 60 would round up and return 60.