Category:Dc: Difference between revisions
Content added Content deleted
(dc commands) |
(array correction & mine also has ~; GNU extension?) |
||
Line 3: | Line 3: | ||
Commands in POSIX dc |
Commands in POSIX dc |
||
number : push a number |
number : push a number |
||
+ - / * % ^ : arithmetic operations |
+ - / * % ^ : arithmetic operations: add sub div mul mod exp |
||
sx Sx : pop the stack and save or push it to register x |
sx Sx : pop the stack and save or push it to register x |
||
lx Lx : copy | pop the register x to main stack. |
lx Lx : copy | pop the register x to main stack. |
||
Line 29: | Line 29: | ||
? : read input and execute. |
? : read input and execute. |
||
Y : debug information |
Y : debug information |
||
a b |
a b :r : store r[b] = a (r is register) |
||
a ;r : retrieve r[b] |
a ;r : retrieve r[b] |
||
Line 35: | Line 35: | ||
n : print value without a new line |
n : print value without a new line |
||
~ : arithmetic - divmod |
|||
| : arithmetic - modular exponentiation |
| : arithmetic - modular exponentiation |
||
r : swap the top two elements |
r : swap the top two elements |
Revision as of 17:34, 9 December 2008
Dc
This programming language may be used to instruct a computer to perform a task.
Listed below are all of the tasks on Rosetta Code which have been solved using Dc.
This programming language may be used to instruct a computer to perform a task.
See Also: |
|
---|
dc is the unix desktop calculator. It uses a reverse polish notation and is turing complete.
Commands in POSIX dc
number : push a number + - / * % ^ : arithmetic operations: add sub div mul mod exp sx Sx : pop the stack and save or push it to register x lx Lx : copy | pop the register x to main stack. d : duplicate top of the stack p : print top of the stack P : pop and print String f : show stack q : exit (drop execution stack by 2) Q : drop execution stack by top of the stack number x : execute dc commands on top of the stack X : replace top of stack by its scale factor. [...] : string notation <x >x =x : compare 2 elements at top of the stack, and execute register x v : square root ! : shell command c : clear i : set input radix from top of stack I : push input base on the top of the stack. o : set output radix from top of stack O : push output base on the top of the stack. k : set scale factor K : get current scale factor z : get the current stack level. Z : get the character length of element at top of stack ? : read input and execute. Y : debug information a b :r : store r[b] = a (r is register) a ;r : retrieve r[b]
GNU Extensions
n : print value without a new line ~ : arithmetic - divmod | : arithmetic - modular exponentiation r : swap the top two elements a : asciify !>r !<r !=r : execute contents of register x based on comparison X : pushes the number of fractional digits # : comment
Subcategories
This category has the following 3 subcategories, out of 3 total.
@
- Dc Implementations (4 P)
- Dc User (10 P)
Pages in category "Dc"
The following 90 pages are in this category, out of 90 total.