문제

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

<html>
    <script>
        var lat = parseFloat(" 25.482688176812758");
        alert(lat);
    </script>
    <body>
    </body>
</html>

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

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top