Andrei's list of barriers to D adoption

Observer via Digitalmars-d digitalmars-d at puremagic.com
Mon Jun 6 11:36:37 PDT 2016


On Monday, 6 June 2016 at 13:10:32 UTC, jmh530 wrote:
> On Monday, 6 June 2016 at 05:49:53 UTC, Ethan Watson wrote:
>>
>> Echoing the need for decimal support. I won't use it myself, 
>> but I know it's critical for finance.
>
> You can always round something to two digits if you need to.

It's more complicated than that.  Part of what you need is to
be able to declare a variable as (say) having two significant
fractional digits, and have the rounding rules be implicitly
applied when saving to that variable, producing an exact
representation of the rounded result in storage.  And part of
the reason for that is that if you compare "3.499" to "3.501"
(as the originally computed numbers) when only 2 sig figs
should be in play, they must compare equal.  This is very much
unlike what happens with binary floating point, where exact
comparisons are rarely possible due to low-order bit differences.
In commercial decimal-arithmetic applications (think "money"),
the low-order bits are supposed to be discarded for almost all
values that actually represent an amount of currency.  For
reliability of the application, this has to be built into the
data type, not dependent on programmer vigilance.  That is,
just like certain other language features, a decimal type
without implicit truncation would be thought of as "doesn't
scale well".


More information about the Digitalmars-d mailing list