Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

floating point not fixed #5

Open
DiedeGu opened this issue Nov 16, 2015 · 2 comments
Open

floating point not fixed #5

DiedeGu opened this issue Nov 16, 2015 · 2 comments

Comments

@DiedeGu
Copy link

DiedeGu commented Nov 16, 2015

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

@ecwyne
Copy link
Owner

ecwyne commented Nov 16, 2015

@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

@ecwyne
Copy link
Owner

ecwyne commented Nov 16, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants