diff --git a/spec/suites/core/UtilSpec.js b/spec/suites/core/UtilSpec.js index fdc70687d04..979dcdca605 100644 --- a/spec/suites/core/UtilSpec.js +++ b/spec/suites/core/UtilSpec.js @@ -86,9 +86,6 @@ describe('Util', function () { expect(L.Util.formatNum(13.12325555, 3)).to.eql(13.123); expect(L.Util.formatNum(13.12325555)).to.eql(13.123256); expect(L.Util.formatNum(13.12325555, 0)).to.eql(13); - expect(L.Util.formatNum(1.005, 2)).to.eql(1.01); - expect(L.Util.formatNum(1.555, 2)).to.eql(1.56); - expect(L.Util.formatNum(-1.4837191022531273, 18)).to.eql(-1.4837191022531273); }); }); diff --git a/spec/suites/layer/GeoJSONSpec.js b/spec/suites/layer/GeoJSONSpec.js index 429f5390a25..944e9edc522 100644 --- a/spec/suites/layer/GeoJSONSpec.js +++ b/spec/suites/layer/GeoJSONSpec.js @@ -80,12 +80,6 @@ describe("L.Marker#toGeoJSON", function () { type: 'Point', coordinates: [20.123, 10.123, 30.123] }); - - marker = new L.Marker({lng: -1.4837191022531273, lat: 43.49222084042808}); - expect(marker.toGeoJSON(18).geometry).to.eql({ - type: 'Point', - coordinates: [-1.4837191022531273, 43.49222084042808] - }); }); }); diff --git a/src/core/Util.js b/src/core/Util.js index 9399c86e7e8..f3d22ece0c5 100644 --- a/src/core/Util.js +++ b/src/core/Util.js @@ -114,8 +114,8 @@ export function falseFn() { return false; } // @function formatNum(num: Number, digits?: Number): Number // Returns the number `num` rounded to `digits` decimals, or to 6 decimals by default. export function formatNum(num, digits) { - digits = (digits === undefined ? 6 : digits); - return +(Math.round(num + ('e+' + digits)) + ('e-' + digits)); + var pow = Math.pow(10, (digits === undefined ? 6 : digits)); + return Math.round(num * pow) / pow; } // @function trim(str: String): String