It is very simple.
If you want to always turn down :
Your required formula:
someLong-someLong%10
This is because someLong%10- this is the remainder of someLongdivided by 10. If you get this from the original number, you will get the desired value.
The generalization is also simple: you can use 100 or even 13 if you want.
If you want to round in the other direction (for example, always round up or always to the middle), then first add something to this number, and then round always down.
If you want to always round:
Then first you need to add 9, and then the round is always down.
someLong+9-(someLong+9)%10
:
... neightbor. , . , 10 :
someLong+5-(someLong+5)%10