dc: Printing Commands

1 
1 3 Printing Commands
1 *******************
1 
1 'p'
1      Prints the value on the top of the stack, without altering the
1      stack.  A newline is printed after the value.
1 
1 'n'
1      Prints the value on the top of the stack, popping it off, and does
1      not print a newline after.  (This command is a GNU extension.)
1 
1 'P'
1      Pops off the value on top of the stack.  If it it a string, it is
1      simply printed without a trailing newline.  Otherwise it is a
1      number, and the integer portion of its absolute value is printed
1      out as a "base (UCHAR_MAX+1)" byte stream.  Assuming that
1      (UCHAR_MAX+1) is 256 (as it is on most machines with 8-bit bytes),
1      the sequence 'KSK0k1/ _1Ss[ls*]Sxd0>x [256~Ssd0<x]dsxx
1      sx[q]Sq[Lsd0>qaPlxx]dsxx sx0sqLqsxLxLK+k' could also accomplish
1      this function.  (Much of the complexity of the above native-dc code
1      is due to the ~ computing the characters backwards, and the desire
1      to ensure that all registers wind up back in their original
1      states.)  (Details of the behavior with a number are a GNU
1      extension.  Traditional 'dc' happened to "support" similar
1      functionality for a limited range of inputs as an accidental
1      side-effect of its internal representation of numbers.)
1 
1 'f'
1      Prints the entire contents of the stack without altering anything.
1      This is a good command to use if you are lost or want to figure out
1      what the effect of some command has been.
1 
1    All numeric output is split to fit within 70 columns, by default.
1 When a number is broken up in this way, the split is indicated by a "\"
1 at the end of the to-be-continued output lines.  The column width at
1 which output is split can be overridden by setting the DC_LINE_LENGTH
1 environment variable to the desired width.  A DC_LINE_LENGTH of 0 (zero)
1 disables the line-split feature altogether.  Invalid values of
1 DC_LINE_LENGTH are silently ignored.  (The DC_LINE_LENGTH variable is a
1 GNU extension.)
1