Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Negative numbers and reverse polish notation

Name: Anonymous 2011-08-26 15:42

In reverse polish notation, how do you write a negative number?
For example, if you were to translate -3-5-8=x, would you write it as -3 5 - 8 - or -3 -5 + -8 +?

Name: Anonymous 2011-08-26 15:43

0 3 - 5 - 8 -

Name: Anonymous 2011-08-26 15:46

Thank you for your help. Have a nice day.

Name: Anonymous 2011-08-26 16:19

You're welcome, I recommend you also take a look at the swaggerific nigger notation in order to avoid this pitfall.

Name: http://xkcd.com/645/ 2011-08-26 17:59

reverse polish sausage

Name: Anonymous 2011-08-26 18:09

That's not about RPN, that's about how the language you use deals with the this bloody binary/unary '-' sign ambiguity.

In Forth for instance, the unary minus is a distinct operator (namely 'NEG').

Another possibility is to take advantage of the fact that the tokens of the language are whitespace delimited; in which case the compiler may accept negative literals. Such a language would let you write -3 -5 -8 + +, even though it defines '-' as a binary operator.

Name: Anonymous 2011-08-26 18:21

>>5
get the fuck out of here

Name: Anonymous 2011-08-26 18:52

>>7
fuck you faggot

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List