Why does D language do not support BigDecimal type?
Cym13
cpicard at purrfect.fr
Tue Mar 12 08:48:33 UTC 2019
On Monday, 11 March 2019 at 15:23:34 UTC, BoQsc wrote:
> There is Money datatype that can be provided by using a third
> party package: https://code.dlang.org/packages/money
>
> But that's only for money, what about math?
> Why such fundamental as BigDecimal is still not included into
> the D language itself?
> There is BigInt.
>
> If it is unavoidable to use Floating point, how can I quickly
> and simply understand the rules of using float to make the
> least error, or should I just find a third party package for
> that as well?
>
>
> There is an article on that, but it is not that straight
> forward:
> https://dlang.org/articles/d-floating-point.html
>
> Basically any thing that I find on Google, that include
> explaining floating point are badly written and hard to
> understand for the outsider lacking ability to understand
> advanced concepts.
How much precision is enough in your use case? There's always a
limit to how precise you need to be and how precise you can be,
be it only because our memory is finite.
I've never had a use case for BigDecimal myself, so forgive my
ignorance, but wouldn't you get the exact same result by using
BigInt?
For example, if you need 20 decimals of precisions then any value
times 10^20 will be a BigInt on which you can work, it's just a
matter of displaying it correctly when outputing the result but
it doesn't change the operations you have to perform.
Is there anything that can't be done with BigInt really?
More information about the Digitalmars-d-learn
mailing list