dc — Desk Calculator

Synopsis

/usr/bin/dc [filename] 

Description

The dc desktop calculator is an arbitrary-precision arithmetic package. Ordinarily, it operates on decimal integers, but you can specify an input base, output base, and a number of fractional digits to be maintained. The dc command uses postfix notation (so-called reverse Polish). With postfix notation, first you type two numbers, one on each line, and then the operator. To print the results on the screen, you type the p command as shown in the following example.

castle% dc
						2
						2
						+
						p 
4 
q 
castle% 

Type q to exit dc.

The dc command also can accept several commands on a single line. You must delimit numbers by white space, but you can run other commands together. For example, you ...

Get Solaris™ 7 Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.