Dee Cee

The "desktop calculator", dc, is a programmable arbitrary-precision RPN calculator for Unix. It was one of the very first languages created under Unix, predating C. It has some reputation both for its arcane commands and the odd wizardly types who like it.

Ironically, although it does arbitrary-precision arithmetic, the maximum call stack is a very low system-dependent number (at least for some implementations). It varies from 900 to a few thousand on modern computers. What's the fun of arbitrary precision if you can't easily compute "100000!"?

Except for certain very minor points regarding arrays, the language is explained completely by the man page. Here's an example (FizzBuzzTest) for inspection. A, B, C and X are macros and n is the main loop variable. Typical dc is quite a bit less structured.

 [sg []] sX
 [
  [Buzz] l5 0 !=X
  [Fizz] l3 0 !=X
  n p sG
 ] sA
 [ln p sG] sB
 [
  ln 3 % s3
  ln 5 % s5
  l3 l5 * d 0 =A 0 !=B
  ln 1 + d sn
  101 >C
 ] sC
 1 sn
 lCx
A compressed and more typical version of the program (65 characters, no whitespace) would be
 [sg[]]sx1[ddd3%d[Fizz]r0!=xnr5%d[Buzz]r0!=xn*0=xpsg1+dd101>M]dsMx
DeeCee has no feature for doing general text input or string manipulation, so an example for BagSumInManyProgrammingLanguages would have to have a convoluted idea of string handling. However, the command P already contains the functionality of printing an arbitrary-size integer as a series of base 256 digits.


See also:


EditText of this page (last edited May 3, 2014) or FindPage with title or text search