Useful but this is a much shorter, simpler and overall less cpu-use way to do it:
(also supports more then just 0.1, 0.01, 0.001, etc.)
PHP Code:
public function roundTo(val, place) {
return int(val/place + 0.5)*place;
}
Two examples:
PHP Code:
myvalue = 53.42;
roundTo(myvalue, 0.1);
myvalue would be 53.4
PHP Code:
myvalue = 53.463;
roundTo(myvalue, 0.05);
myvalue would be 53.45
Basically this just takes value and rounds it to the closest "place".
(Didn't see this thread till just now

)