Suppose I have Long someLong = 1004L
. What efficient method can I use to round this down to 1000L
? Note that I do not actually know that someLong == 1004L
so I can't simply do someLong -= 4L;
. I need a generalizable method. I also want the ability to round down to each 5
instead of each 10
, for example a function to round to 1005L
(since if we're rounding by 5
's then it'll round up instead of down).
More examples .. It could be that I have 1926L
and I want to round to 5
meaning I need 1925L
. Or I need to round to 10
meaning I need 1930L
.