Polish Notation - Arithmetic

Arithmetic

The expression for adding the numbers 1 and 2 is, in prefix notation, written "+ 1 2" rather than "1 + 2". In more complex expressions, the operators still precede their operands, but the operands may themselves be nontrivial expressions including operators of their own. For instance, the expression that would be written in conventional infix notation as

(5 − 6) * 7

can be written in prefix as

* (− 5 6) 7

Since the simple arithmetic operators are all binary (at least, in arithmetic contexts), any prefix representation thereof is unambiguous, and bracketing the prefix expression is unnecessary. As such, the previous expression can be further simplified to

* − 5 6 7

The processing of the product is deferred until its two operands are available (i.e., 5 minus 6, and 7). As with any notation, the innermost expressions are evaluated first, but in prefix notation this "innermost-ness" can be conveyed by order rather than bracketing.

In the classical notation, the parentheses in the infix version were required, since moving them

5 − (6 * 7)

or simply removing them

5 − 6 * 7

would change the meaning and result of the overall expression, due to the precedence rule.

Similarly

5 − (6 * 7)

can be written in Polish notation as

− 5 * 6 7

Read more about this topic:  Polish Notation

Famous quotes containing the word arithmetic:

    O! O! another stroke! that makes the third.
    He stabs me to the heart against my wish.
    If that be so, thy state of health is poor;
    But thine arithmetic is quite correct.
    —A.E. (Alfred Edward)

    ‘Tis no extravagant arithmetic to say, that for every ten jokes,—thou hast got an hundred enemies; and till thou hast gone on, and raised a swarm of wasps about thine ears, and art half stung to death by them, thou wilt never be convinced it is so.
    Laurence Sterne (1713–1768)

    Your discovery of the contradiction caused me the greatest surprise and, I would almost say, consternation, since it has shaken the basis on which I intended to build my arithmetic.... It is all the more serious since, with the loss of my rule V, not only the foundations of my arithmetic, but also the sole possible foundations of arithmetic seem to vanish.
    Gottlob Frege (1848–1925)