Comments (10)
Ok, that's a little weird, I will look into it.
0*log(0) should certainly return NAN or possibly throw an exception. As a mathematician, I prefer to leave 0^0 undefined, even though I realize that 0^0=1 is often a useful convention.
(It's not hard to write a custom Evaluator making sure 0^0 returns 1, though.)
from math-parser.
@byCedric Thank you for the report, I think that should fix it.
from math-parser.
@byCedric Looking forward to it!
from math-parser.
Haha, I will never force a mathematician to some common conventions. Thanks for the tip on creating a custom evaluator, will definitely look into it. If I can help, you can message me anytime. Again, thanks for this library and your quick response!
from math-parser.
I had a look at the 0*log(0)
issue. It is due to some slightly overaggressive simplification in the parser. I will think of how to fix this without losing some simplifications that I'd like to keep, but it might take a few days.
In the meantime (and for your use case, it won't hurt much), try
$parser = new StdMathParser(); // or RationalMathParser if you prefer
$parser->setSimplifying(false);
and 0*log(0)
will evaluate to NAN
as expected.
from math-parser.
Actually, with setSimplifying(false)
, you will also get 0^0 = 1
for free.
from math-parser.
You are the best! If I can help you on something, you can always message me. Thanks you once again for your quick response and good workarounds!
from math-parser.
I don't know if this is related or if I should open up a new issue. Right now we have an exception (non math-exception) being thrown when the expression !1
is being evaluated.
With version 1.2.3 this threw an UnknownTokenException: Unknown token 0 encountered in Lexing/Lexer.php on line 85
which is correct. But as of 1.3.3 a Uncaught Error: Call to a member function accept() on null in Interpreting/Evaluator.php:186
is being thrown. I briefly tried to find the cause, but I'm still searching.
from math-parser.
This doesn't seem to be related. 1.3.0 added support for factorials, so "!1" shouldn't throw a UnknownTokenException
, but it should throw a SyntaxErrorException
instead. It seems like some malformed expressions containing !
slips through the Parser. I'll check it out.
from math-parser.
Thank you once again for your quick fix! If you are ever visiting Amsterdam I will buy you a beer or something!
from math-parser.
Related Issues (20)
- Too much useless dependances in composer HOT 1
- PHP_Timer not found, old phpunit version ? HOT 2
- Unknown constant `i` HOT 3
- Negative numbers on the right hand side of an operator throw a Syntax Error HOT 4
- Questions about functions using commas and ** operator HOT 3
- Issue with variable e HOT 3
- improve/fix type hints HOT 1
- New Operator request HOT 1
- How to evaluate custom functions inside expressions? (documentation) HOT 2
- Max,Min Functions HOT 1
- Support PHP 8 HOT 2
- Adding custom constants
- Improve exception usability HOT 2
- Support currency/dollar value
- it is required to add support for the % operator
- How to extract all variables from an expression?
- Evaluator.php triggers PHP type error HOT 1
- Support fraction shorthand operator HOT 4
- Parser.php tries to call unknown function HOT 2
- Guide for new users HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from math-parser.