[Prev][Next][Index][Thread]

Re: Currency and Dylan




Chris Double wrote in message ...
>What approaches do people use for dealing with dollar values in Dylan?
>In particular, making the dollar/cents add up
>correctly. <double-float>? <integer>? A special currency class?
>Reading/writing the dollar valuse to/from files as well. How do I do
>this with floats for example?


Definitely used scale integers.  If you've got dollars and cents,
you'll probably want to scale by 3 or even 4 powers of ten.
(BTW, I'm assuming you might want taxation, which is why
scaling by 2 powers of ten isn't enough.)

So, $20.00 would be represented as 200000 if you scale by
4 powers of ten.  I would use double integers, or possibly even
as class that represents dollars and cents as two slots.





Follow-Ups: References: