how do I round off a given number to the nearest multiple of 10 in elixir
It’s probably like rounding the tenth of the value… and multiply by 10.
round_ten = fn(n) -> round(n / 10) * 10 end
Well, you didn’t specified the rounding method, so I assume that any will do:
def round10(n) when rem(n, 10) < 6, do: n - rem(n, 10) def round10(n), do: n + (10 - rem(n, 10))
Thanks a lot, it has worked