Proposal for a standard Decimal type in alpha

Jack Stouffer jack at jackstouffer.com
Fri Dec 22 01:55:54 UTC 2017


On Thursday, 21 December 2017 at 23:08:22 UTC, Andre Pany wrote:
> That are fantastic news. Thanks for working on this topic.
> Is it possible to define a decimal type with a defined scale 
> and precision?
> From the examples and the documentation I am not sure whether 
> it is possible.

Yes, the Hook template parameter currently controls how many 
significant digits your decimal can have and will eventually be 
able to control the min and max allowed exponents as well. By 
default, it's set at 9 digits, but you can have as many as 
int.max - 1 since it auto uses BigInt under the hood. Once your 
decimal has more than the allowed number of digits, it's rounded 
according to the Hook prescribed rounding method, which is half 
up by default.


More information about the Digitalmars-d-announce mailing list