36 lines
897 B
Text
36 lines
897 B
Text
[ $ "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
|