[OT] -10^2

Jan Schenkel janschenkel at yahoo.com
Fri May 23 02:49:01 EDT 2003


--- Geoff Canyon <gcanyon at inspiredlogic.com> wrote:
> 
> On Thursday, May 22, 2003, at 09:53  PM, David
> Vaughan wrote:
> 
> > -10  2  ^
> > and
> > 10  2  ^  -
> 
> How do you (the interpreter) know that in the second
> example the - is a 
> unary operator vs. a binary operator?
> 
> regards,
> 
> Geoff Canyon

Because you have to read RPN as follows:
- you read from left to right
- if it's a number, push it onto the stack
- if it's a binary opearator, pop the last two numbers
oif the stack, calculate and push the result onto the
stack

So in this case, after all the firsty three bits are
interpreted, there's only a single operand left on the
stack for the minus, so it acts as the unary operator.

Hope this clears it up,

Jan Schenkel.

=====
"As we grow older, we grow both wiser and more foolish at the same time."  (La Rochefoucauld)

__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com



More information about the use-livecode mailing list