mround

fun mround(x: Double, granularity: Double): Double

Contributed by Andrew Gibson round a scalar double to a multiple of granularity note that 0 a granularity value is interpreted as "no rounding"

Granularity represents the finest division of the measurement scale. For example, a 12-inch rule that has inches divided into 4 quarters has a granularity of 1/4 or 0.25. The function rounds the supplied double to the nearest multiple of the granularity.

For example,

mround(3.1459, granularity = 0.25) = 3.25 mround(3.0459, granularity = 0.25) = 3.0

See this stack overflow post for further information.

Return

x rounded to granularity

Parameters

x
  • input

granularity

a scalar Double