Skip to content
This repository has been archived by the owner on May 23, 2019. It is now read-only.

Arbitrary precision causes errors #93

Open
staab opened this issue Jan 9, 2019 · 1 comment
Open

Arbitrary precision causes errors #93

staab opened this issue Jan 9, 2019 · 1 comment

Comments

@staab
Copy link

staab commented Jan 9, 2019

I'm using algebra.js probably not as intended; I'm using it to actually solve some equations within my application. But it's super helpful, so I'd like to make it work. It appears that numbers with a lot of precision don't remain integers somewhere along the way. The following code:

algebra
  .parse('((23/25C + 297176318895199/312500000000000)*(0.5))-50-((23/25C + 297176318895199/312500000000000)*(0.09))')
  .eval({C: new Fraction(29114907, 5000)})

Gives me an error:

Uncaught TypeError: Invalid Argument (52412560532480240,24414062500000.004): Divisor and dividend must be of type Integer.
    at new Fraction (node_modules/algebra.js/src/fractions.js:12:15)
    at Fraction.copy (node_modules/algebra.js/src/fractions.js:17:12)
    at Fraction.reduce (node_modules/algebra.js/src/fractions.js:21:21)
    at Fraction.add (node_modules/algebra.js/src/fractions.js:77:29)
    at node_modules/algebra.js/src/expressions.js:28:57
    at Array.reduce (<anonymous>)
    at Expression.constant (node_modules/algebra.js/src/expressions.js:28:27)
    at Expression.simplify (node_modules/algebra.js/src/expressions.js:41:28)
    at Expression.add (node_modules/algebra.js/src/expressions.js:73:59)
    at node_modules/algebra.js/src/expressions.js:187:52
@CrazyAlien
Copy link

CrazyAlien commented Jan 15, 2019

Same happened to me
Seems the bigger the fractions it will fallback to real numbers

-142307/7392403695x^3 + 11282782/2464134565x^2 + 31471476791/7392403695x - 112183397497/492826913

algebra.js:1 Uncaught TypeError: Invalid Argument (-154542566.00000003,7392403695.000001): Divisor and dividend must be of type Integer.

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

No branches or pull requests

2 participants