Currency: Difference between revisions
Added Quackery.
(Added Quackery.) |
|||
Line 1,631:
--------------------
Total 23683000000000006.16</pre>
=={{header|Quackery}}==
<syntaxhighlight lang="Quackery"> [ $ "bigrat.qky" loadfile ] now!
[ 100 * n->v ] is dollars ( n --> n/d )
[ n->v v+ ] is cents ( n/d n --> n/d )
[ rot n->v v* ] is cost ( n n/d --> n/d )
[ $->v drop v* 100 n->v v/ ] is tax ( n/d $ --> n/d )
[ 100 n->v v/
2 point$
$ " $" swap join
' [ 2 split nip ] ]do[
dup -3 peek
char . = if done
dup -2 peek
char . = iff
[ char 0 join ]
done
$ ".00" join ] is currency$ ( n/d --> $ )
[ currency$ echo$ ] is echocurrency ( n/d --> )
4000000000000000 5 dollars 50 cents cost
2 2 dollars 86 cents cost v+
say "Total price before tax: " 2dup echocurrency cr
2dup $ "7.65" tax
say "Tax: " 2dup echocurrency cr
v+
say "Total price with tax: " echocurrency cr
</syntaxhighlight>
{{out}}
<pre>Total price before tax: $22000000000000005.72
Tax: $1683000000000000.44
Total price with tax: $23683000000000006.16</pre>
=={{header|Racket}}==
|