Replies: 4 comments 9 replies
-
The expression parser evaluates this expression as follows: math.evaluate('50%')
// = 50 * 0.01
// = 0.5
math.evaluate('50% + 20%')
// = (50 * 0.01) + 20%
// = 0.5 + 20%
// = 0.5 * 1.2
// = 0.6 If you want to get the result of 30%, you can provide parenthesis, like: math.evaluate('(10 + 20)%')
// 0.3 The percentage operator is listed here in the docs: https://mathjs.org/docs/expressions/syntax.html Does that help? |
Beta Was this translation helpful? Give feedback.
-
I think the original post does raise a legitimate issue that |
Beta Was this translation helpful? Give feedback.
-
Yes you're right, it would be much more intuitive to evaluate OK I'll move this into a discussion/idea. We'll have to think though how we can support this and in what cases exactly. |
Beta Was this translation helpful? Give feedback.
-
I haven't looked at parse trees yet so am not really ready to put forward any concrete possibilities. But conceivably |
Beta Was this translation helpful? Give feedback.
-
Hi,
I am fairly new to using
mathjs
and I have been using it for my excel-like datasheets on my online application.However, recently I have seen an issue with evaluating decimal numbers, even the simplest expression does not output the correct answer, or what I believe should be correct.
Describe the bug
I am getting a weird output as follows:
I believe the correct output should be 30 (%)
Could I get some clarification pls?
Thanks :)
Beta Was this translation helpful? Give feedback.
All reactions