Phate6660 / bcalc

A pure-bash calculator in which I even wrote my own lexer and parser for.
Other
5 stars 1 forks source link

Show error message when more than 2 numbers are entered #1

Closed adnan360 closed 3 years ago

adnan360 commented 3 years ago

Thanks for creating the project.

First, I tried:

$ ./bcalc '1+1'
2
$ ./bcalc '(1+1)*2'
12
$ ./bcalc '2*(1+1)'
13

The last 2 are wrong. Then I found Support operating on more than two numbers on the TODO list. I think it's better to show an error message that more than 2 numbers are not supported, rather than showing wrong results. Some users could be really confused, like me! :)

Phate6660 commented 3 years ago

Done! It will display "Only 2 numbers are supported for now." and exit with an error code of 1 if more than 2 numbers are supplied.

Phate6660 commented 3 years ago

But something like this is high priority. There shouldn't be a 2 number restriction for too long I hope.

adnan360 commented 3 years ago

Done! It will display "Only 2 numbers are supported for now." and exit with an error code of 1 if more than 2 numbers are supplied.

Thanks.

But something like this is high priority. There shouldn't be a 2 number restriction for too long I hope.

Thanks for taking this seriously. If PEMDAS is implemented this would be a serious project to look forward to. I'll also try to implement it in my config.