I would choose the standard of actual division by the number by which you divide it, and rounding, and then multiplying. This seems to be the right method of work that you can use with any number and maintain a mental image of what you are trying to achieve.
var val = 26.14, factor = 0.05; val = Math.round(val / factor) * factor;
This will work for tens, hundreds or any number. If you specifically round the number above, use Math.ceil
instead of Math.round
.
Another method specifically designed to round to 1 or more decimal places (rather than half) is as follows:
Number(Number(1.5454545).toFixed(1));
It creates a string with a fixed number, and then turns it into a real Number
.
source share