Browse Source

Merge pull request #6 from ryanxcharles/feature/fix-truncation-error

fix truncation error in parseValue
patch-2
Ryan X. Charles 11 years ago
parent
commit
02ddbbd146
  1. 5
      test/util-util.js
  2. 1
      util/util.js

5
test/util-util.js

@ -16,7 +16,10 @@ describe('util/util', function(){
[ "1.0", "100000000" ],
[ "0.1", "10000000" ],
[ ".1", "10000000" ],
[ "0.0005", "50000" ]
[ "0.0005", "50000" ],
[ ".000000001", "0" ],
[ ".000000009", "0" ],
[ ".00000000000000001", "0" ]
];
dataValues.forEach(function(datum) { test_value(datum); });
});

1
util/util.js

@ -113,6 +113,7 @@ var reWholeVal = /^\s*(\d+)/;
function padFrac(frac)
{
frac=frac.substr(0,8); //truncate to 8 decimal places
while (frac.length < 8)
frac = frac + '0';
return frac;

Loading…
Cancel
Save