Category:Dc

From Rosetta Code

Jump to: navigation, search
Language
Dc
This programming language may be used to instruct a computer to perform a task.
Execution method: Interpreted
Type checking: Dynamic
See Also:


Listed below are all of the tasks on Rosetta Code which have been solved using Dc.
Your Help Needed
If you know Dc, please write code for some of the tasks not implemented in Dc.
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.

@

Pages in category "Dc"

The following 7 pages are in this category, out of 7 total.

C

E

F

G

H

L

T

Personal tools
Support