user3416285 user3416285 - 1 year ago 134
Javascript Question

parseFloat bug in IE

It seems a very simple question.
the result of parseFloat in IE is different from the results in Chrome and FF.
Here is the very simple code

var lat = parseFloat(" 25.482688176812758");

then try to open it in IE the alert is 25.482688176812757
but in chrome and FF is 25.482688176812758

Answer Source

It's the browser limitation of decimal places in implementation of Numbers.

A workaround is to use the library BigDecimal.

More on Floating-point cheat sheet for JavaScript.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download