Decimal/Currency Type
Zane via Digitalmars-d
digitalmars-d at puremagic.com
Tue Aug 9 03:48:50 PDT 2016
There has been a question or two about this before, but I really
don't feel there has been a reasonable answer (or I have missed
it).
I am wondering if there is a fixed decimal type, either built-in
or implemented in Phobos (similar to python's "Decimal" or Java's
"BigDecimal").
Previous posts suggested using a long and keeping track of the
decimal point, but there are a few problems with that. First,
arithmatic with, or assignments from, other types wouldn't
translate properly (the built in types have no awareness of the
decimal point location associated with the long). Second, if
using for currency as an example, I could probably get by with
long if only tracking cents, but what if I wanted to track
thousandths of a cent or more? That wouldn't leave me with much
place values to track large dollar amounts.
Is there such a thing build into D? If not, is there any plans to
add it? It seems like this would be something needed by many
applications (especially anything dealing with currency).
More information about the Digitalmars-d
mailing list