Currency: Difference between revisions
Content added Content deleted
mNo edit summary |
(added RPL) |
||
Line 1,984: | Line 1,984: | ||
total price after tax : 23683000006.16 |
total price after tax : 23683000006.16 |
||
</pre> |
</pre> |
||
=={{header|RPL}}== |
|||
Need for big integers. |
|||
{{works with|RPL|HP-49C}} |
|||
« →STR |
|||
'''IF''' LASTARG 9 ≤ '''THEN''' "0" SWAP + '''END''' |
|||
1 OVER SIZE 2 - SUB |
|||
LASTARG NIP 1 + DUP 1 + SUB |
|||
"$" ROT SIZE LASTARG "0" IFTE + |
|||
"." + SWAP + |
|||
» '<span style="color:blue">→CURR</span>' STO |
|||
« 100 * R→I * |
|||
DUP <span style="color:blue">→CURR</span> CLLCD 1 DISP .5 WAIT |
|||
» '<span style="color:blue">→PRICE</span>' STO |
|||
« DUPDUP FLOOR - EVAL →NUM |
|||
0.5 ≥ SWAP CEIL LASTARG FLOOR IFTE |
|||
» '<span style="color:blue">→RND</span>' STO |
|||
« 100 * R→I |
|||
OVER <span style="color:blue">→CURR</span> "TPBT" →TAG |
|||
UNROT OVER * 100000 / <span style="color:blue">→RND</span> DUP <span style="color:blue">→CURR</span> "Tax" →TAG |
|||
UNROT + <span style="color:blue">→CURR</span> "TPWT" →TAG |
|||
» '<span style="color:blue">TAX→</span>' STO |
|||
4000000000000000 5.50 <span style="color:blue">→PRICE</span> |
|||
2 2.86 <span style="color:blue">→PRICE</span> + |
|||
7.65 <span style="color:blue">TAX→</span> |
|||
{{out}} |
|||
<pre> |
|||
3: TPBT:"$22000000000000005.72" |
|||
2: Tax:"$1683000000000000.44" |
|||
1: TPWT:"$23683000000000006.16" |
|||
</pre> |
|||
=={{header|Ruby}}== |
=={{header|Ruby}}== |
||
<syntaxhighlight lang="ruby">require 'bigdecimal/util' |
<syntaxhighlight lang="ruby">require 'bigdecimal/util' |