Knowledge (XXG)

dc (computer program)

Source đź“ť

2382: 2404: 683:, which execute the specified macro if the top two values on the stack are greater, less than or equal to ("not greater"), less than, greater than or equal to ("not less than"), and not equals, respectively. Note that the order of the operands in inequality comparisons is the opposite of the order for arithmetic; 900:
Downsides of this solution are: the loop stops on encountering a blank line in the input stream (technically, any input line which does not add at least one numeric value to the stack); and, for handling negative numbers, leading instances of '-' to denote a negative sign must be change to '_' in the
1156:
A fast divide and conquer implementation of the same formula that doubles in size each iteration. It evaluates a finite number if sums as an exact rational number and only performs one large division and square root per iteration. It is fast, but will still quickly slow down as the size of the
623:
Macros are then implemented by allowing registers and stack entries to be strings as well as numbers. A string can be printed, but it can also be executed (i.e. processed as a sequence of dc commands). So for instance we can store a macro to add one and then multiply by 2 into register m:
1144:
in the programming language dc. The program will print better and better approximations as it runs. But as pi is a transcendental number, the program will continue until interrupted or resource exhaustion of the machine it is run on.
800:
operator reads another command from the input stream. If the input line contains a decimal number, that value is added to the stack. When the input file reaches end of file, the command is null, and no value is added to the stack.
1479:, the output of number digits (according to the output base) will be restricted to this value, inserting thereafter backslashes and newlines. The default line length is 70. The special value of 0 disables line breaks. 419: 599:
character, or if the top of the stack is a string it replaces it with the first character of the string. There are no ways to build up strings or perform string manipulation other than executing it with the
892:
Note that since dc supports arbitrary precision, there is no concern about numeric overflow or loss of precision, no matter how many lines the input stream contains, unlike a similarly concise solution in
493:
command does the same for the output base, but keep in mind that the input base affects the parsing of every numeric value afterwards so it is usually advisable to set the output base first. Therefore
303:
This translates into "push four and five onto the stack, then, with the multiplication operator, pop two elements from the stack, multiply them and push the result onto the stack." Then the
924:
converts distances from metres to feet and inches; the bulk of it is concerned with prompting for input, printing output in a suitable format and looping around to convert another number.
1018: 1067:
This program was written by Michel Charpentier. It outputs the sequence of prime numbers. Note that shorter implementation is possible, which reads fourteen symbols less.
459:
command. This evaluates the line as if it were a dc command, and so it is necessary that it be syntactically correct and presents a potential security problem because the
1477: 489:
command pops the top of the stack and uses it for the input base. Hex digits must be in upper case to avoid collisions with dc commands and are limited to A-F. The
2455: 169:
This article provides some examples in an attempt to give a general flavour of the language; for a complete list of commands and syntax, one should consult the
711:
Looping is then possible by defining a macro which (conditionally) reinvokes itself. A simple factorial of the top of the stack might be implemented as:
2450: 1770: 353: 1692: 2445: 2430: 1178: 572:
Registers can also be treated as secondary stacks, so values can be pushed and popped between them and the main stack using the
2395: 2390: 1603: 311:
command quits the invoked instance of dc. Note that numbers must be spaced from each other even as some operators need not be.
135: 2440: 143: 34: 1577: 1193:
debates, where the short script could be run with only Perl and dc, ubiquitous programs on Unix-like operating systems:
1763: 777:
A bare number is a valid dc expression, so this can be used to sum a file where each line contains a single number.
750:
which conditionally calls itself, performing an addition each time, until only one value remains on the stack. The
2367: 2337: 1738: 1488: 159: 39: 784:
which conditionally calls itself, performing an addition each time, until only one value remains on the stack.
326:) to be used for arithmetic operations. Since the default precision is zero, this sequence of commands produces 2460: 2352: 1493: 548: 194: 158:. Like other utilities of that vintage, it has a powerful set of features but terse syntax. Traditionally, the 155: 68: 1262:
command can be used to do arbitrary precision modular exponentiation without needing to write the X function.
1124:
Note that the latter can be sped up even more, if the access to a constant is replaced by a register access.
1508: 937: 558:, which in dc is a storage location with a single character name which can be stored to and retrieved from: 131: 2435: 2408: 2113: 1782: 1756: 1748: 973: 1727: 88: 1624:
A nerdy delight for any Vintage Computer Fest 2019 attendee: Kernighan interviewing Thompson about Unix
1254:
A commented version is slightly easier to understand and shows how to use loops, conditionals, and the
905:
operator in dc does not provide a clean way to discern reading a blank line from reading end of file.
2283: 2231: 1443: 1141: 725:
quits from two levels of macros (and dc itself if there are less than two levels on the call stack).
315: 210: 53: 754:
operator is used to push the number of entries in the stack onto the stack. The comparison operator
933: 112: 107: 57: 1956: 1946: 95: 1449: 1036: 513:
commands push the current precision, input radix and output radix on to the top of the stack.
497:
sets the output radix to the current input radix, but generally not to 10 (ten). Nevertheless
2183: 2088: 2083: 1696: 75: 714:# F(x): return x! # if x-1 > 1 # return x * F(x-1) # otherwise # return x dsFxp 2362: 2306: 2211: 2012: 1915: 1182: 501:
resets the output base to 10 (ten), regardless of the input base. To read the values, the
2301: 2236: 2221: 2158: 2118: 1997: 1961: 1855: 1498: 340:, an arbitrary number of decimal places can be produced. This command sequence outputs 307:
command is used to examine (print out to the screen) the top element on the stack. The
163: 139: 128: 100: 30: 2424: 2342: 2203: 2138: 1910: 1885: 1786: 1503: 547:
In addition to these basic arithmetic and stack operations, dc includes support for
2316: 2216: 2133: 2128: 2032: 1941: 1905: 1860: 1667: 1554: 1446:
DC_LINE_LENGTH exists and contains an integer that is greater than 1 and less than
198: 1733: 1607: 1560:
A Research Unix reader: annotated excerpts from the Programmer's Manual, 1971–1986
1039:
in the programming language dc; programs that produce its source code as output.
322:, which sets the number of fractional digits (the number of digits following the 2252: 2226: 2163: 2153: 2143: 2108: 2098: 2093: 1976: 1966: 1920: 323: 1558: 2068: 2027: 1830: 1800: 1622: 1581: 1186: 913:
As an example of a relatively simple program in dc, this command (in 1 line):
645:
Finally, we can use this macro mechanism to provide conditionals. The command
197:—was the first language to run on the new computer, even before an assembler. 47: 25: 2357: 2311: 2291: 2188: 2168: 2123: 1971: 1895: 1880: 1865: 1850: 1845: 1840: 1835: 967: 186: 147: 84: 1646: 1647:"Advanced Bash-Scripting Guide, Chapter 16, Example 16-52 (Factorization)" 649:
pops two values from the stack, and executes the macro stored in register
2273: 2053: 1714: 1539: 1372:# Since e may be very large, this uses the property that g^e % m == 591:
characters and may be pushed onto the stack and stored in registers. The
414:{\displaystyle {\sqrt {\left(12+\left(-3\right)^{4}\right) \over 11}}-22} 170: 2078: 2002: 634:
command which executes the top of the stack) we can use it like this:
201:
has opined that dc was the very first program written on the machine.
2063: 1805: 1198:#!/usr/bin/perl -- -export-a-crypto-system-sig Diffie-Hellman-2-lines 190: 1721: 1363:# It is the same as Sm^Lm%, but handles arbitrarily large exponents. 474:
pops the top of the stack and prints it without a trailing newline.
2296: 2193: 2173: 2103: 2022: 1925: 1900: 1875: 1825: 1820: 1815: 1810: 1710: 1535: 596: 482: 452: 1529: 1163:'1Sk1SR13591409dSBSP426880dSQ4/3^9*SCs-dSoxdszxscsy0dslx' 595:
command converts the low order byte of the numeric value into an
2347: 2321: 2257: 2178: 2073: 2058: 2017: 2007: 1951: 1779: 1258:
command to return from a macro. With the GNU version of dc, the
1190: 1174: 182: 151: 80: 1752: 1704: 2148: 2048: 1992: 1890: 1130:"P?sF2s2dvsr2sf4s4d2%0=F3sfd3%0=F5sfsNdsMxsMd1<M" 894: 901:
input stream, because of dc's nonstandard negative sign. The
657:
only if the top two values on the stack are of equal value:
566:
pushes the value of register c onto the stack. For example:
1870: 562:
pops the top of the stack and stores it in register c, and
551:, conditionals and storing of results for later retrieval. 780:
This is again implemented with a macro stored in register
1578:"The sources for the manual page for 7th Edition Unix dc" 1534:: an arbitrary precision calculator â€“  758:
pops two values off the stack in making the comparison.
1119:"P?sFdvsr2sfd2%0=F3sfd3%0=F5sfsNdsMxsMd1<M" 554:
The mechanism underlying macros and conditionals is the
209:
To multiply four and five in dc (note that most of the
1354:# Function Q: remove the top of the stack and return 1 1091:
This program was also written by Michel Charpentier.
721:
command exits from a macro, allowing an early return.
1452: 976: 470:
prints the top of the stack with a newline after it.
425:
computes the square root of the top of the stack and
356: 746:
This is implemented with a macro stored in register
2330: 2282: 2266: 2245: 2202: 2041: 1985: 1934: 1793: 1105:and a faster solution (try with the 200-bit number 700: 688: 615:character begins a comment to the end of the line. 435:To swap the top two elements of the stack, use the 106: 94: 74: 64: 46: 24: 1471: 1012: 842:The input lines can also be complex dc commands. 653:only if they are equal. So this prints the string 413: 243:The results are also available from the commands: 1360:# Function X(e): recursively compute g^e % m 478:prints the entire stack with one entry per line. 1396:d 0=Q # return 1 if e==0 (otherwise, stack: e) 932:As an example, here is an implementation of the 463:dc command enables arbitrary command execution. 16:Cross-platform reverse-Polish calculator program 1173:A more complex example of dc use embedded in a 439:command. To duplicate the top element, use the 154:utilities, preceding even the invention of the 1604:"The Evolution of the Unix Timesharing System" 516:As an example, to convert from hex to binary: 1764: 773:Summing all dc expressions as lines from file 8: 1249:`echo "16dio1SX$ e"\EszlXx+p | dc` 481:dc also supports arbitrary input and output 19: 1086:'P?s2s12sid2%0=13sidvsrds.xd1<2' 2403: 1771: 1757: 1749: 729:pushes the current stack depth before the 18: 1566:(Technical report). CSTR. Bell Labs. 139. 1457: 1451: 1001: 990: 975: 388: 357: 355: 1549: 1547: 1342:# Read m, e and g from stdin on one line 696: 692: 684: 1520: 1420:le # Load e from the register 1414:lm % # compute (g^e) % m 1348:# Function z: return g * top of stack 429:is used to input a negative number): 7: 2456:Stack-oriented programming languages 1013:{\displaystyle n!=\prod _{i=1}^{n}i} 1668:"Diffie–Hellman in 2 lines of Perl" 1399:d 2% Sa # Store e%2 in a (stack: e) 173:for one's specific implementation. 1627:. YouTube. Event occurs at 29m45s 1621:Brian Kernighan and Ken Thompson. 1423:lXx # compute g^e % m 764:"1 2 4 8 16 100 0ddsaxp" 14: 1411:La1=z # multiply by g if e%2==1 604:command, or printing it with the 2402: 2381: 2380: 532:11011110101011011011111011101111 336:By adjusting the precision with 185:language program. When its home 166:) was implemented on top of dc. 2451:Numerical programming languages 1602:Ritchie, Dennis M. (Sep 1979). 1333:`echo $ g $ e $ m | dc -e ' 1426:p # Print the result 1151:'_640320sP3^sj7sndsMx' 588:String values are enclosed in 136:arbitrary-precision arithmetic 1: 1730:Programmer's Manual, Volume 1 1369:# Stack at exit: g^e % m 1318:"$ 0 gen exp mod\n" 1240:"$ 0 gen exp mod\n" 1100:"P?sFsJdvsr2sfdsMx" 1062:'2p3ps#s@s&ds.x' 919:'PAP]shszPnPAPdx]dx' 318:is changed with the command 1384:# if( e % 2 == 1 ) 1179:Diffie–Hellman key exchange 1169:Diffie–Hellman key exchange 181:dc is the oldest surviving 2477: 1408:d* # compute X(e/2)^2 1055:Printing all prime numbers 432:12 _3 4 ^ + 11 / v 22 - p 220:cat<<EOF>cal.txt 150:. It is one of the oldest 134:calculator which supports 40:AT&T Bell Laboratories 2446:Free mathematics software 2376: 1489:bc (programming language) 1140:An implementation of the 695:runs the contents of the 162:calculator program (with 1494:Calculator input methods 1472:{\displaystyle 2^{16}-1} 1264: 1195: 1181:. This was popular as a 1159: 1147: 1126: 1115: 1096: 1082: 1069: 1058: 1041: 1021: 956:# easier-to-read version 942: 915: 844: 803: 786: 760: 742:Summing the entire stack 518: 265: 245: 215: 2431:Cross-platform software 1509:Reverse Polish notation 1381:# x = (g^(e/2)) ^ 2 1073:'2p3ps$ s#ds.x' 928:Greatest common divisor 889:And the result is 42. 839:And the result is 12. 769:And the result is 131. 663:Other conditionals are 2396:Unix SUS2008 utilities 2391:Standard Unix programs 1783:command-line interface 1473: 1336:# Hex input and output 1014: 1006: 415: 156:C programming language 1474: 1438:Environment variables 1405:lXx # call X(e/2) 1402:2/ # compute e/2 1390:# return x % 1157:fraction increases. 1079:Integer factorization 1015: 986: 953:'P?P?dsax+Pp' 416: 2441:Software calculators 2284:Software development 1742:, which includes dc. 1450: 1444:environment variable 1142:Chudnovsky algorithm 974: 630:and then (using the 466:As mentioned above, 451:To read a line from 354: 316:arithmetic precision 138:. It was written by 1734:Native Windows port 1366:# Stack at entry: e 1094:There is a shorter 970:of an input value, 934:Euclidean algorithm 884:"0ddsaxp" 834:"0ddsaxp" 790:"0ddsaxp" 254:"4 5 * p" 21: 1469: 1378:# return 1 1375:# if( e == 0 ) 1177:script performs a 1025:'?sQdsFxp' 1010: 946:'??dsax+p' 411: 26:Original author(s) 2418: 2417: 1713:General Commands 1303:"\U$ _" 1045:'93Pn]dx' 1035:There exist also 871:"5dd++" 862:"4 3 *" 853:"3 5 *" 699:register because 538:Language features 403: 402: 298:'4 5 * p' 118: 117: 2468: 2406: 2405: 2384: 2383: 1986:User environment 1773: 1766: 1759: 1750: 1725: 1724: 1708: 1707: 1697:Debian GNU/Linux 1679: 1678: 1676: 1674: 1663: 1657: 1656: 1654: 1653: 1643: 1637: 1636: 1634: 1632: 1618: 1612: 1611: 1606:. Archived from 1599: 1593: 1592: 1590: 1589: 1580:. Archived from 1574: 1568: 1567: 1565: 1551: 1542: 1533: 1532: 1525: 1478: 1476: 1475: 1470: 1462: 1461: 1433: 1430: 1427: 1424: 1421: 1418: 1415: 1412: 1409: 1406: 1403: 1400: 1397: 1394: 1391: 1388: 1387:# x *= g 1385: 1382: 1379: 1376: 1373: 1370: 1367: 1364: 1361: 1358: 1355: 1352: 1349: 1346: 1343: 1340: 1337: 1334: 1331: 1328: 1325: 1322: 1319: 1316: 1313: 1310: 1307: 1304: 1301: 1298: 1295: 1292: 1289: 1286: 1283: 1280: 1277: 1274: 1271: 1268: 1261: 1257: 1250: 1247: 1244: 1241: 1238: 1235: 1232: 1229: 1226: 1223: 1220: 1217: 1214: 1211: 1208: 1205: 1202: 1199: 1164: 1152: 1131: 1120: 1112: 1108: 1101: 1087: 1074: 1063: 1050: 1046: 1026: 1019: 1017: 1016: 1011: 1005: 1000: 957: 954: 950: 947: 920: 904: 885: 881: 878: 875: 872: 869: 866: 863: 860: 857: 854: 851: 848: 835: 831: 828: 825: 822: 819: 816: 813: 810: 807: 799: 791: 783: 765: 757: 753: 749: 732: 728: 724: 720: 702: 690: 682: 678: 674: 670: 666: 656: 652: 648: 633: 614: 607: 603: 594: 590: 579: 575: 565: 561: 533: 529: 525: 522: 512: 508: 504: 500: 496: 492: 488: 477: 473: 469: 462: 458: 442: 438: 428: 424: 420: 418: 417: 412: 404: 398: 394: 393: 392: 387: 383: 359: 358: 343: 339: 329: 321: 310: 306: 299: 295: 292: 289: 286: 283: 279: 276: 273: 269: 258: 255: 252: 249: 239: 236: 232: 229: 226: 223: 219: 205:Basic operations 193:, dc—written in 76:Operating system 22: 2476: 2475: 2471: 2470: 2469: 2467: 2466: 2465: 2461:Plan 9 commands 2421: 2420: 2419: 2414: 2372: 2326: 2278: 2262: 2241: 2198: 2042:Text processing 2037: 1981: 1930: 1789: 1777: 1746: 1720: 1719: 1703: 1702: 1688: 1683: 1682: 1672: 1670: 1665: 1664: 1660: 1651: 1649: 1645: 1644: 1640: 1630: 1628: 1620: 1619: 1615: 1601: 1600: 1596: 1587: 1585: 1576: 1575: 1571: 1563: 1553: 1552: 1545: 1528: 1527: 1526: 1522: 1517: 1485: 1453: 1448: 1447: 1440: 1435: 1434: 1431: 1428: 1425: 1422: 1419: 1416: 1413: 1410: 1407: 1404: 1401: 1398: 1395: 1392: 1389: 1386: 1383: 1380: 1377: 1374: 1371: 1368: 1365: 1362: 1359: 1356: 1353: 1350: 1347: 1344: 1341: 1338: 1335: 1332: 1329: 1326: 1323: 1320: 1317: 1314: 1311: 1308: 1305: 1302: 1299: 1296: 1293: 1290: 1287: 1284: 1281: 1278: 1275: 1272: 1269: 1267:#!/usr/bin/perl 1266: 1259: 1255: 1252: 1251: 1248: 1245: 1242: 1239: 1236: 1233: 1230: 1227: 1224: 1221: 1218: 1215: 1212: 1209: 1206: 1203: 1200: 1197: 1183:signature block 1171: 1166: 1165: 1162: 1154: 1153: 1150: 1138: 1133: 1132: 1129: 1122: 1121: 1118: 1110: 1106: 1103: 1102: 1099: 1089: 1088: 1085: 1081: 1076: 1075: 1072: 1065: 1064: 1061: 1057: 1052: 1051: 1048: 1044: 1033: 1028: 1027: 1024: 972: 971: 964: 959: 958: 955: 952: 948: 945: 930: 922: 921: 918: 911: 909:Unit conversion 902: 887: 886: 883: 879: 876: 873: 870: 867: 864: 861: 858: 855: 852: 849: 846: 837: 836: 833: 829: 826: 823: 820: 817: 814: 811: 808: 805: 797: 794: 793: 789: 781: 775: 767: 766: 763: 755: 751: 747: 744: 739: 730: 726: 722: 718: 715: 709: 698: 694: 686: 680: 676: 672: 668: 664: 661: 654: 650: 646: 643: 638: 631: 628: 621: 612: 605: 601: 592: 589: 586: 577: 573: 570: 563: 559: 545: 540: 535: 534: 531: 527: 523: 520: 510: 506: 502: 498: 494: 490: 486: 475: 471: 467: 460: 456: 449: 440: 436: 433: 426: 422: 376: 372: 371: 364: 360: 352: 351: 348: 341: 337: 334: 327: 319: 308: 304: 301: 300: 297: 293: 290: 287: 284: 281: 277: 274: 271: 267: 261: 260: 256: 253: 250: 247: 241: 240: 237: 234: 230: 227: 224: 221: 217: 207: 179: 125:desk calculator 37: 17: 12: 11: 5: 2474: 2472: 2464: 2463: 2458: 2453: 2448: 2443: 2438: 2433: 2423: 2422: 2416: 2415: 2413: 2412: 2400: 2399: 2398: 2393: 2377: 2374: 2373: 2371: 2370: 2368:true and false 2365: 2360: 2355: 2350: 2345: 2340: 2334: 2332: 2328: 2327: 2325: 2324: 2319: 2314: 2309: 2304: 2299: 2294: 2288: 2286: 2280: 2279: 2277: 2276: 2270: 2268: 2264: 2263: 2261: 2260: 2255: 2249: 2247: 2243: 2242: 2240: 2239: 2234: 2229: 2224: 2219: 2214: 2208: 2206: 2204:Shell builtins 2200: 2199: 2197: 2196: 2191: 2186: 2181: 2176: 2171: 2166: 2161: 2156: 2151: 2146: 2141: 2136: 2131: 2126: 2121: 2116: 2111: 2106: 2101: 2096: 2091: 2086: 2081: 2076: 2071: 2066: 2061: 2056: 2051: 2045: 2043: 2039: 2038: 2036: 2035: 2030: 2025: 2020: 2015: 2010: 2005: 2000: 1995: 1989: 1987: 1983: 1982: 1980: 1979: 1974: 1969: 1964: 1959: 1954: 1949: 1944: 1938: 1936: 1932: 1931: 1929: 1928: 1923: 1918: 1913: 1908: 1903: 1898: 1893: 1888: 1883: 1878: 1873: 1868: 1863: 1858: 1853: 1848: 1843: 1838: 1833: 1828: 1823: 1818: 1813: 1808: 1803: 1797: 1795: 1791: 1790: 1787:shell builtins 1778: 1776: 1775: 1768: 1761: 1753: 1744: 1743: 1731: 1717: 1700: 1687: 1686:External links 1684: 1681: 1680: 1658: 1638: 1613: 1610:on 2010-05-06. 1594: 1569: 1555:McIlroy, M. D. 1543: 1538:User Commands 1519: 1518: 1516: 1513: 1512: 1511: 1506: 1501: 1499:HP calculators 1496: 1491: 1484: 1481: 1468: 1465: 1460: 1456: 1439: 1436: 1265: 1196: 1170: 1167: 1160: 1148: 1137: 1136:Calculating Pi 1134: 1127: 1116: 1097: 1083: 1080: 1077: 1070: 1059: 1056: 1053: 1049:'P]dx' 1042: 1032: 1029: 1022: 1009: 1004: 999: 996: 993: 989: 985: 982: 979: 966:Computing the 963: 960: 943: 929: 926: 916: 910: 907: 845: 804: 787: 774: 771: 761: 743: 740: 738: 735: 713: 708: 705: 659: 642: 639: 636: 626: 620: 617: 585: 582: 569:3 sc 4 lc * p 568: 544: 541: 539: 536: 526:16i2oDEADBEEFp 519: 448: 445: 431: 410: 407: 401: 397: 391: 386: 382: 379: 375: 370: 367: 363: 346: 332: 266: 246: 216: 213:is optional): 206: 203: 178: 175: 164:infix notation 140:Lorinda Cherry 132:reverse-Polish 129:cross-platform 116: 115: 110: 104: 103: 101:Cross-platform 98: 92: 91: 78: 72: 71: 66: 62: 61: 50: 44: 43: 31:Lorinda Cherry 28: 15: 13: 10: 9: 6: 4: 3: 2: 2473: 2462: 2459: 2457: 2454: 2452: 2449: 2447: 2444: 2442: 2439: 2437: 2436:Unix software 2434: 2432: 2429: 2428: 2426: 2411: 2410: 2401: 2397: 2394: 2392: 2389: 2388: 2387: 2379: 2378: 2375: 2369: 2366: 2364: 2361: 2359: 2356: 2354: 2351: 2349: 2346: 2344: 2341: 2339: 2336: 2335: 2333: 2331:Miscellaneous 2329: 2323: 2320: 2318: 2315: 2313: 2310: 2308: 2305: 2303: 2300: 2298: 2295: 2293: 2290: 2289: 2287: 2285: 2281: 2275: 2272: 2271: 2269: 2267:Documentation 2265: 2259: 2256: 2254: 2251: 2250: 2248: 2244: 2238: 2235: 2233: 2230: 2228: 2225: 2223: 2220: 2218: 2215: 2213: 2210: 2209: 2207: 2205: 2201: 2195: 2192: 2190: 2187: 2185: 2182: 2180: 2177: 2175: 2172: 2170: 2167: 2165: 2162: 2160: 2157: 2155: 2152: 2150: 2147: 2145: 2142: 2140: 2137: 2135: 2132: 2130: 2127: 2125: 2122: 2120: 2117: 2115: 2112: 2110: 2107: 2105: 2102: 2100: 2097: 2095: 2092: 2090: 2087: 2085: 2082: 2080: 2077: 2075: 2072: 2070: 2067: 2065: 2062: 2060: 2057: 2055: 2052: 2050: 2047: 2046: 2044: 2040: 2034: 2031: 2029: 2026: 2024: 2021: 2019: 2016: 2014: 2011: 2009: 2006: 2004: 2001: 1999: 1996: 1994: 1991: 1990: 1988: 1984: 1978: 1975: 1973: 1970: 1968: 1965: 1963: 1960: 1958: 1955: 1953: 1950: 1948: 1945: 1943: 1940: 1939: 1937: 1933: 1927: 1924: 1922: 1919: 1917: 1914: 1912: 1909: 1907: 1904: 1902: 1899: 1897: 1894: 1892: 1889: 1887: 1884: 1882: 1879: 1877: 1874: 1872: 1869: 1867: 1864: 1862: 1859: 1857: 1854: 1852: 1849: 1847: 1844: 1842: 1839: 1837: 1834: 1832: 1829: 1827: 1824: 1822: 1819: 1817: 1814: 1812: 1809: 1807: 1804: 1802: 1799: 1798: 1796: 1792: 1788: 1785:programs and 1784: 1781: 1774: 1769: 1767: 1762: 1760: 1755: 1754: 1751: 1747: 1741: 1740: 1735: 1732: 1729: 1726: â€“  1723: 1718: 1716: 1712: 1709: â€“  1706: 1701: 1698: 1694: 1690: 1689: 1685: 1669: 1662: 1659: 1648: 1642: 1639: 1626: 1625: 1617: 1614: 1609: 1605: 1598: 1595: 1584:on 2004-08-23 1583: 1579: 1573: 1570: 1562: 1561: 1556: 1550: 1548: 1544: 1541: 1537: 1531: 1524: 1521: 1514: 1510: 1507: 1505: 1504:Stack machine 1502: 1500: 1497: 1495: 1492: 1490: 1487: 1486: 1482: 1480: 1466: 1463: 1458: 1454: 1445: 1437: 1263: 1194: 1192: 1188: 1184: 1180: 1176: 1168: 1158: 1146: 1143: 1135: 1125: 1114: 1095: 1092: 1078: 1068: 1054: 1040: 1038: 1030: 1020: 1007: 1002: 997: 994: 991: 987: 983: 980: 977: 969: 961: 941: 939: 935: 927: 925: 914: 908: 906: 898: 896: 890: 843: 840: 821:"7" 812:"5" 802: 785: 778: 772: 770: 759: 741: 736: 734: 712: 706: 704: 687:evaluates to 660:p] sm 5 5 =m 658: 640: 635: 625: 618: 616: 609: 598: 583: 581: 567: 557: 552: 550: 542: 537: 517: 514: 484: 479: 464: 454: 446: 444: 430: 408: 405: 399: 395: 389: 384: 380: 377: 373: 368: 365: 361: 345: 331: 330:as a result: 325: 317: 312: 264: 244: 214: 212: 204: 202: 200: 196: 192: 188: 184: 176: 174: 172: 167: 165: 161: 157: 153: 149: 145: 144:Robert Morris 141: 137: 133: 130: 126: 122: 114: 111: 109: 105: 102: 99: 97: 93: 90: 86: 82: 79: 77: 73: 70: 67: 63: 59: 55: 51: 49: 45: 41: 36: 35:Robert Morris 32: 29: 27: 23: 2407: 2385: 1745: 1737: 1699:repositories 1671:. Retrieved 1661: 1650:. Retrieved 1641: 1631:September 3, 1629:. Retrieved 1623: 1616: 1608:the original 1597: 1586:. Retrieved 1582:the original 1572: 1559: 1523: 1441: 1253: 1172: 1155: 1139: 1123: 1104: 1093: 1090: 1066: 1034: 1031:Quines in dc 965: 936:to find the 931: 923: 912: 899: 891: 888: 841: 838: 795: 779: 776: 768: 745: 716: 710: 662: 644: 641:Conditionals 629: 622: 610: 587: 571: 555: 553: 546: 515: 480: 465: 450: 447:Input/output 434: 350:To evaluate 349: 347:5 k 2 3 / p 335: 313: 302: 262: 242: 208: 199:Ken Thompson 180: 168: 124: 120: 119: 48:Developer(s) 1794:File system 1666:Adam Back. 1189:during the 1187:cypherpunks 733:operation. 189:received a 54:open-source 2425:Categories 2386:Categories 1652:2020-09-20 1588:2004-06-23 1515:References 949:# shortest 580:commands. 455:, use the 233:dccal.txt 211:whitespace 65:Written in 60:developers 58:commercial 2246:Searching 1935:Processes 1464:− 988:∏ 968:factorial 962:Factorial 792:<file 693:5 3 <t 689:5 - 3 = 2 637:3 lm x p 608:command. 543:Registers 443:command. 406:− 378:− 187:Bell Labs 148:Bell Labs 85:Unix-like 2054:basename 1691:Package 1557:(1987). 1483:See also 1111:2 200^1- 737:Examples 701:3 < 5 556:register 333:2 3 / p 171:man page 96:Platform 52:Various 2159:strings 2079:dirname 2003:logname 1952:crontab 1442:If the 1345:?SmSeSg 1109:(input 584:Strings 483:radices 177:History 127:) is a 113:Command 2139:printf 2064:csplit 1806:chattr 1728:Plan 9 1715:Manual 1540:Manual 1429:'` 1321:unless 1185:among 1037:quines 691:, but 619:Macros 549:macros 485:. The 342:.66666 272:4 5*pq 191:PDP-11 89:Plan 9 2363:sleep 2317:strip 2297:ctags 2232:unset 2212:alias 2194:xargs 2174:troff 2134:patch 2129:paste 2104:iconv 2033:write 2023:uname 1926:umask 1916:touch 1906:split 1901:rmdir 1876:mkdir 1861:fuser 1826:cksum 1821:chgrp 1816:chown 1811:chmod 1722:dc(1) 1711:Linux 1705:dc(1) 1673:5 Jan 1564:(PDF) 1536:Linux 1530:dc(1) 1339:16dio 1330:print 1309:@ARGV 1246:print 1225:@ARGV 707:Loops 685:5 3 - 677:!< 669:!> 655:equal 597:ASCII 453:stdin 324:point 282:4 5 * 222:4 5 * 2409:List 2348:expr 2322:yacc 2307:make 2258:grep 2253:find 2237:wait 2227:test 2222:echo 2179:uniq 2164:tail 2154:sort 2144:read 2119:more 2109:join 2099:head 2094:fold 2074:diff 2059:comm 2018:tput 2013:talk 2008:mesg 1998:exit 1977:time 1967:nice 1962:kill 1921:type 1856:file 1780:Unix 1675:2009 1633:2019 1417:] SX 1191:ITAR 1175:Perl 1161:dc-e 1149:dc-e 1128:dc-e 1117:dc-e 1098:dc-e 1084:dc-e 1071:dc-e 1060:dc-e 1047:dc-e 1043:dc-e 1023:dc-e 951:dc-e 944:dc-e 917:dc-e 882:dc-e 868:echo 859:echo 850:echo 832:dc-e 818:echo 809:echo 796:The 788:dc-e 762:dc-e 756:> 717:The 673:< 665:> 611:The 576:and 524:echo 509:and 314:The 296:dc-e 270:dc- 251:echo 183:Unix 152:Unix 142:and 108:Type 81:Unix 56:and 2343:cal 2302:lex 2274:man 2149:sed 2069:cut 2049:awk 2028:who 1993:env 1911:tee 1891:pwd 1886:pax 1831:cmp 1801:cat 1736:of 1695:in 1324:$ m 1315:die 1297:map 1288:$ m 1282:$ e 1276:$ g 1237:die 1231:$ m 1216:$ m 1210:$ e 1204:$ g 1107:2-1 938:GCD 895:AWK 627:sm 530:dc 521:$ 495:10o 421:: ( 294:$ 280:dc 278:$ 268:$ 263:or 259:dc 248:$ 231:$ 228:EOF 218:$ 146:at 87:, 2427:: 2358:od 2353:lp 2338:bc 2312:nm 2292:ar 2217:cd 2189:wc 2184:vi 2169:tr 2124:nl 2114:m4 2089:ex 2084:ed 1972:ps 1957:fg 1947:bg 1942:at 1896:rm 1881:mv 1871:ls 1866:ln 1851:df 1846:du 1841:dd 1836:cp 1739:bc 1693:dc 1546:^ 1459:16 1357:sQ 1351:sz 1270:my 1234:|| 1113:) 940:: 897:. 719:1Q 703:. 681:!= 679:, 675:, 671:, 667:, 647:=r 564:lc 560:sc 505:, 499:Ao 409:22 400:11 366:12 344:. 288:20 275:20 238:$ 235:20 160:bc 121:dc 83:, 33:, 20:dc 1772:e 1765:t 1758:v 1677:. 1655:. 1635:. 1591:. 1467:1 1455:2 1432:; 1393:[ 1327:; 1312:; 1306:} 1300:{ 1294:= 1291:) 1285:, 1279:, 1273:( 1260:| 1256:q 1243:; 1228:, 1222:= 1219:) 1213:, 1207:, 1201:( 1008:i 1003:n 998:1 995:= 992:i 984:= 981:! 978:n 903:? 880:| 877:} 874:; 865:; 856:; 847:{ 830:| 827:} 824:; 815:; 806:{ 798:? 782:a 752:z 748:a 731:z 727:z 723:q 697:t 651:r 632:x 613:# 606:P 602:x 593:a 578:L 574:S 528:| 511:O 507:I 503:K 491:o 487:i 476:f 472:n 468:p 461:! 457:? 441:d 437:r 427:_ 423:v 396:) 390:4 385:) 381:3 374:( 369:+ 362:( 338:k 328:0 320:k 309:q 305:p 291:q 285:p 257:| 225:p 195:B 123:( 69:B 42:) 38:(

Index

Original author(s)
Lorinda Cherry
Robert Morris
AT&T Bell Laboratories
Developer(s)
open-source
commercial
B
Operating system
Unix
Unix-like
Plan 9
Platform
Cross-platform
Type
Command
cross-platform
reverse-Polish
arbitrary-precision arithmetic
Lorinda Cherry
Robert Morris
Bell Labs
Unix
C programming language
bc
infix notation
man page
Unix
Bell Labs
PDP-11

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.

↑