Simple calculator in java parser

I am currently making a simple calculator calculator in Java, dealing only with the + and - operators and integers. I read about postfix and infix , and I wonder if brackets can be used with any of these methods?

+3
source share
2 answers

The beauty of the prefix / prefix means you don't need parentheses. Brackets are used in infix notation because ambiguities exist, for example:

a + b - c

This may mean one of the following:

(a + b) - c
a + (b - c)

However, in postfix notation, they clearly differ:

a b + c -
a b c - +

No parentheses / brackets are needed to ensure the order of evaluation in postfix notation.

see also


Convert from infix

infix , . " " Edsger Dijkstra.

.

+5

+ - , , , , .

, , , - -

0

Source: https://habr.com/ru/post/1752259/


All Articles