Open DiedeGu opened 8 years ago
@DiedeGu where are you able to properly evaluate 0.1 + 0.2
?
When I go to mathjs.org and evaluate the following in my console:
math.eval('0.1 + 0.2');
it returns 0.30000000000000004 (the expected javascript floating point output) See this cool video about floating point math in javasctipt
Hi Ecwyne,
I am using math.js in a package and am writing tests for it. Currently I require the package like this. api.use('ecwyne:mathjs'); . The package works but the two decimal addition tests fail while in the online demo the same addition gives a correct result. Am I using the package in the wrong way / Do I still need to require the mathjs package?
it('eval returns 0.3 for 0.1 + 0.2', function(){ expect(math.eval('0.1 + 0.2')).toBe(0.3); });
it('select returns 0.3 for 0.1 + 0.2', function(){ expect(math.select(0.1).add(0.2).done()).toBe(0.3); });
Thanks in advanced