On Tuesday, 12 March 2019 at 08:48:33 UTC, Cym13 wrote:
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?
Please attach quick working examples for every sentence you write
or it's just a waste of time. People want to see the results and
direct actions first before anything else, it's more efficient
communication. We are in the subforum of Dlang learn, after all.
Do not write "For Example".
I'm interested in writing a simple game prototype and I imagine
that I would like to include some item parts in decimal. (100.00)
To keep everything simple I would like to make my code as clean
and simple as possible. Floating points seems to require
additional arithmetics - rounding and are inprecise when
comparing. I do not want to deal with it every time. But if there
is any standard simple documentation that I could include into my
own game documentation to avoid confusion and make everything
consisten, I would like to know.
For now it seems that the only way to make it all simple is to
use some kind of library to handle decimals for me, as I can't
find any concise references on how to correctly use and
understand floating points.