math.simplify with Fractions #2678
Unanswered
chrisbansart
asked this question in
Q&A
Replies: 1 comment
-
Thanks, glad to hear you like mathjs 👍 Have a look at the output of the console.log(math.Fraction('1/7').toString()) \\ "0.(142857)"
console.log(math.Fraction('9/7').toString()) \\ "1.(285714)" The output (sometimes) contains a special notation to denote repeating sequences.The expression parser of mathjs doesn't support that though, and Ideally, you should be able to just pass a Fraction to math.simplify(math.fraction('1/7'))
math.simplify(math.fraction('9/7')) What does just work though is: math.simplify('1/7')
math.simplify('9/7') (though there isn't anything to simplify in those specific cases) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi all mathjs contributors,
First of all thanks a lot for the incredible job you've achieved, math.js is really useful and impressive. I've figured out unexpected behaviour when using simplify with Fractions.
For instance:
math.simplify(math.Fraction('1/7').toString()) -> returns Object { value: 0 } => Seems to be the integer part
math.simplify(math.Fraction('9/7').toString()) -> returns Object { value: 285714 } => Seems to be the decimal part
Nevertheless
math.simplify(math.Fraction('5/4').toString()) -> returns a tree Object { implicit: false, isPercentage: false, op: "/", fn: "divide", args: (2) […] } with seems to contain the fraction.
Do you have any rational explanations ?. I use simplify with my programs that mix fractions with simplify and several times (1 out of 20 times) it occurs wrong results.
Kind regards
Chris
Beta Was this translation helpful? Give feedback.
All reactions