In Javascript i solved this issue (after two years) by using:

****
function round(number) {
        return parseFloat(number.toPrecision(12));
}
****

The "toPrecision(12)" rounds to 12 significant digits which is well within 
acceptable tolerances for my practical application:
http://www.quickconvert.net/index.html
http://www.quickconvert.net/javascript/calculate.js

It does however leave trailing zeros below the decimal point. I 
found "parseFloat()" stripped those nicely.

Is there a PHP equivalent way to tidy double float math? I intend to offer a 
real form alternative to those not using Javascript on this site.

-- 
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]

Reply via email to