# (calc.info)Stack Basics

Next: Numeric Entry Prev: Help Commands Up: Introduction
Enter node , (file) or (file)node
```
5.3 Stack Basics
================

Calc uses RPN notation.  If you are not familar with RPN, Note: RPN
Tutorial.

To add the numbers 1 and 2 in Calc you would type the keys: `1 <RET>
2 +'.  (<RET> corresponds to the <ENTER> key on most calculators.)  The
first three keystrokes "push" the numbers 1 and 2 onto the stack.  The
`+' key always "pops" the top two numbers from the stack, adds them,
and pushes the result (3) back onto the stack.  This number is ready for
further calculations:  `5 -' pushes 5 onto the stack, then pops the 3
and 5, subtracts them, and pushes the result (-2).

Note that the "top" of the stack actually appears at the _bottom_ of
the buffer.  A line containing a single `.' character signifies the end
of the buffer; Calculator commands operate on the number(s) directly
above this line.  The `d t' (`calc-truncate-stack') command allows you
to move the `.' marker up and down in the stack; Note: Truncating the
Stack.

Stack elements are numbered consecutively, with number 1 being the
top of the stack.  These line numbers are ordinarily displayed on the
lefthand side of the window.  The `d l' (`calc-line-numbering') command
controls whether these numbers appear.  (Line numbers may be turned off
since they slow the Calculator down a bit and also clutter the display.)

The unshifted letter `o' (`calc-realign') command repositions the
cursor to its top-of-stack "home" position.  It also undoes any
horizontal scrolling in the window.  If you give it a numeric prefix
argument, it instead moves the cursor to the specified stack element.

The <RET> (or equivalent <SPC>) key is only required to separate two
consecutive numbers.  (After all, if you typed `1 2' by themselves the
Calculator would enter the number 12.)  If you press `RET' or `SPC'
_not_ right after typing a number, the key duplicates the number on the
top of the stack.  `<RET> *' is thus a handy way to square a number.

The <DEL> key pops and throws away the top number on the stack.  The
<TAB> key swaps the top two objects on the stack.  Note: Stack and
Trail, for descriptions of these and other stack-related commands.

```

automatically generated by info2www version 1.2.2.9