Is there an equivalent of the decimal type in D?
Sean Kelly
sean at f4.ca
Sat Jan 27 15:33:22 PST 2007
Sean Kelly wrote:
> Jeff Nowakowski wrote:
>> Sean Kelly wrote:
>>> Unless you're simply dealing with numbers too large to be represented
>>> exactly with floating-point (16 digits for 64-bit double, and I can't
>>> remember the limit for 80-bit real offhand), I think it makes more
>>> sense to use floating point internally and round to the appropriate
>>> degree of precision for display.
>>
>> Floating point is a very bad idea for representing money. If you're
>> adding up currencies then you want an exact representation, not "close
>> enough". Sooner or later you will get bitten by rounding error if you
>> use floats.
>
> And this is more of a problem than rounding error with BCD? Most BCD
> representations I've seen only use around 6 decimal places, which is far
> too few in some cases.
Perhaps this is my source of confusion. Does Java's BigDecimal support
arbitrary precision after the decimal point?
Sean
More information about the Digitalmars-d-learn
mailing list