Proposal for a standard Decimal type in alpha
rumbu
rumbu at rumbu.ro
Wed Mar 14 17:45:55 UTC 2018
On Wednesday, 14 March 2018 at 15:18:18 UTC, Jordi Gutiérrez
Hermoso wrote:
> On Wednesday, 14 March 2018 at 14:57:12 UTC, rumbu wrote:
>> For 20 decimal digits, you can use decimal128 (having a 34
>> decimal digits precision) and set the context precision to 20.
>>
>> http://rumbu13.github.io/decimal/doc/decimal.html#.DecimalControl.precision
>
> I would also sometimes like around 1000 decimal digits. It's
> fun to compute digits of pi, especially today (or zeta(3) or
> whatever). Can yours do that?
To store 1000 decimal digits you will need 3322 bits. My decimal
implementation is performance/precision oriented not arbitrary
precision oriented. What you'll need is a BigFloat or BigDecimal
type.
At the origin, my decimal implementation used an unlimited bit
width, but trying to compile it with an width greater than 1024
bits resulted in out of memory or in compilation times measured
in tens of minutes, therefore I limited the use to 128 bit, as
requested in the IEEE 754-2008 standard.
For your needs Jack's solution
(https://github.com/JackStouffer/stdxdecimal) is better since
it's using BigInt as storage, therefore you'll have any arbitrary
precision you desire.
More information about the Digitalmars-d-announce
mailing list