-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add support for arbitrary-length numbers #10
Comments
$parser = Parser::createDefault();
$expression = $parser->parse("--1 + 1");
var_dump($expression->evaluate());
// Expect: int(2)
// Result: Error: Unexpected token encountered at (1:5) "-1+1" when parsing "--1+1" |
|
For "Invalid Input" I think it should throw an error instead of returning |
IMO, devs should consider checking for bounds for their application as capping at INT_MIN/MAX is expected behaviour among various programming languages. |
One way to support arbitrary-length integers would be by having a separate bcadd(string $num1, string $num2, ?int $scale = null): string
gmp_abs(GMP|int|string $num): GMP they would interfere with functions such as |
$parser = Parser::createDefault();
$expression = $parser->parse("9223372036854775807 - 1 + 1");
var_dump($expression->evaluate()); // int(9223372036854775807) same expression but $parser = Parser::createDefault();
$expression = $parser->parse("9223372036854775807 + 1 - 1");
var_dump($expression->evaluate()); // float(9.223372036854776E+18) |
That is expected behaviour as well according to how PHP performs the operation. |
The text was updated successfully, but these errors were encountered: