From d12dce4c92c92f23fb1602aa98fb1154ffa25549 Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Fri, 15 Dec 2017 12:51:17 -0500 Subject: [PATCH 1/8] dc: add page --- pages/common/dc.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 pages/common/dc.md diff --git a/pages/common/dc.md b/pages/common/dc.md new file mode 100644 index 000000000..34516f37f --- /dev/null +++ b/pages/common/dc.md @@ -0,0 +1,19 @@ +# dc + +> An arbitrary precision calculator. Uses reverse polish notation (RPN). + +- Run calculator in interactive mode: + +`dc` + +- Calculate 4 times 5 [4 5 *] subtract 17 [17 -] and [p]rint the output : + +`echo "4 5 * 17 - p"| dc` + +- Set number of decimal places to 10 [k 7], calculate 5 divided by -3 [5 _3 /] and [p]rint: + +`echo "7 k 5 _3 / p" | dc` + +- To 100 decimal places [100 k] , calculate the golden ratio, phi, sqrt(5) [5 v] plus 1 [1 +], divided by 2 [2 /] and [p]rint result: + +`echo "100 k 5 v 1 + 2 / p" | dc` From 89cac75cff48a22446201a9267dcfcf621fe8f0e Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Fri, 15 Dec 2017 12:56:44 -0500 Subject: [PATCH 2/8] Remove trailing space --- pages/common/dc.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/common/dc.md b/pages/common/dc.md index 34516f37f..a4feaa2eb 100644 --- a/pages/common/dc.md +++ b/pages/common/dc.md @@ -16,4 +16,4 @@ - To 100 decimal places [100 k] , calculate the golden ratio, phi, sqrt(5) [5 v] plus 1 [1 +], divided by 2 [2 /] and [p]rint result: -`echo "100 k 5 v 1 + 2 / p" | dc` +`echo "100 k 5 v 1 + 2 / p" | dc` From 12e4418ffb378a578ddf146cfb2371fb41f82f1d Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Fri, 15 Dec 2017 12:59:36 -0500 Subject: [PATCH 3/8] Fix spacing and commas. Me write English ungood --- pages/common/dc.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pages/common/dc.md b/pages/common/dc.md index a4feaa2eb..a05650c61 100644 --- a/pages/common/dc.md +++ b/pages/common/dc.md @@ -6,7 +6,7 @@ `dc` -- Calculate 4 times 5 [4 5 *] subtract 17 [17 -] and [p]rint the output : +- Calculate 4 times 5 [4 5 *], subtract 17 [17 -], and [p]rint the output : `echo "4 5 * 17 - p"| dc` @@ -14,6 +14,6 @@ `echo "7 k 5 _3 / p" | dc` -- To 100 decimal places [100 k] , calculate the golden ratio, phi, sqrt(5) [5 v] plus 1 [1 +], divided by 2 [2 /] and [p]rint result: +- To 100 decimal places [100 k], calculate the golden ratio, phi, sqrt(5) [5 v] plus 1 [1 +], divided by 2 [2 /], and [p]rint result: `echo "100 k 5 v 1 + 2 / p" | dc` From 40547b8295674e6d482345022163cb28dd522c6c Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Fri, 15 Dec 2017 13:00:16 -0500 Subject: [PATCH 4/8] Use a colon instead of comma --- pages/common/dc.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/common/dc.md b/pages/common/dc.md index a05650c61..33c60e784 100644 --- a/pages/common/dc.md +++ b/pages/common/dc.md @@ -14,6 +14,6 @@ `echo "7 k 5 _3 / p" | dc` -- To 100 decimal places [100 k], calculate the golden ratio, phi, sqrt(5) [5 v] plus 1 [1 +], divided by 2 [2 /], and [p]rint result: +- To 100 decimal places [100 k], calculate the golden ratio, phi: sqrt(5) [5 v] plus 1 [1 +], divided by 2 [2 /], and [p]rint result: `echo "100 k 5 v 1 + 2 / p" | dc` From 5c0854ae0fd0a905d1c8e0954e16da3a8da3a2d2 Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Fri, 15 Dec 2017 17:12:48 -0500 Subject: [PATCH 5/8] Add examples with 'dc -f' and 'dc -e' --- pages/common/dc.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pages/common/dc.md b/pages/common/dc.md index 33c60e784..cf6f47f8c 100644 --- a/pages/common/dc.md +++ b/pages/common/dc.md @@ -6,14 +6,19 @@ `dc` -- Calculate 4 times 5 [4 5 *], subtract 17 [17 -], and [p]rint the output : +- Execute dc script in file: + +`dc -f {{file}}` + +- Calculate 4 times 5 [4 5 *], subtract 17 [17 -], and [p]rint the output (using echo): `echo "4 5 * 17 - p"| dc` -- Set number of decimal places to 10 [k 7], calculate 5 divided by -3 [5 _3 /] and [p]rint: +- Set number of decimal places to 10 [k 7], calculate 5 divided by -3 [5 _3 /] and [p]rint (using dc -e): -`echo "7 k 5 _3 / p" | dc` +`dc -e "7 k 5 _3 / p"` - To 100 decimal places [100 k], calculate the golden ratio, phi: sqrt(5) [5 v] plus 1 [1 +], divided by 2 [2 /], and [p]rint result: -`echo "100 k 5 v 1 + 2 / p" | dc` +`dc -e "100 k 5 v 1 + 2 / p"` + From 5d1e62095eca1eca8dc8a388f677adc515369a27 Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Fri, 15 Dec 2017 17:13:20 -0500 Subject: [PATCH 6/8] Remove extra newline --- pages/common/dc.md | 1 - 1 file changed, 1 deletion(-) diff --git a/pages/common/dc.md b/pages/common/dc.md index cf6f47f8c..1528ee8dc 100644 --- a/pages/common/dc.md +++ b/pages/common/dc.md @@ -21,4 +21,3 @@ - To 100 decimal places [100 k], calculate the golden ratio, phi: sqrt(5) [5 v] plus 1 [1 +], divided by 2 [2 /], and [p]rint result: `dc -e "100 k 5 v 1 + 2 / p"` - From 38fa3557692f139247caf5b440ca5fd070cd41ea Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Sat, 16 Dec 2017 15:18:43 -0500 Subject: [PATCH 7/8] Fix typo --- pages/common/dc.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/common/dc.md b/pages/common/dc.md index 1528ee8dc..34dac02c1 100644 --- a/pages/common/dc.md +++ b/pages/common/dc.md @@ -14,7 +14,7 @@ `echo "4 5 * 17 - p"| dc` -- Set number of decimal places to 10 [k 7], calculate 5 divided by -3 [5 _3 /] and [p]rint (using dc -e): +- Set number of decimal places to 7 [7 k], calculate 5 divided by -3 [5 _3 /] and [p]rint (using dc -e): `dc -e "7 k 5 _3 / p"` From 757901f9a099cb43dbbc04505b9df726225ee5d1 Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Sun, 17 Dec 2017 16:47:56 -0500 Subject: [PATCH 8/8] Consistent use of k operator --- pages/common/dc.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/common/dc.md b/pages/common/dc.md index 34dac02c1..b54fc14da 100644 --- a/pages/common/dc.md +++ b/pages/common/dc.md @@ -18,6 +18,6 @@ `dc -e "7 k 5 _3 / p"` -- To 100 decimal places [100 k], calculate the golden ratio, phi: sqrt(5) [5 v] plus 1 [1 +], divided by 2 [2 /], and [p]rint result: +- Calculate the golden ratio, phi: Set number of decimal places to 100 [100 k], square root of 5 [5 v] plus 1 [1 +], divided by 2 [2 /], and [p]rint result: `dc -e "100 k 5 v 1 + 2 / p"`