Money type

Steven Schveighoffer schveiguy at
Wed Jan 1 21:06:56 UTC 2020

On 1/1/20 3:20 PM, Ola Fosheim Grøstad wrote:
> On Wednesday, 1 January 2020 at 19:01:36 UTC, Steven Schveighoffer wrote:
>> That is what I use. Fixed point with a factor of power of 10. In other 
>> words, a fixed point number with 2 decimal places would be sufficient 
>> for such currency. When doing math on such types, you just need to 
>> deal with the underlying numbers, and it works fine.
> You don't need fixed point, just store cents in 64 bit floating point 
> and you get at least the same accuracy as a 53 bit integer fixed point.

It is stored that way. Stored as a long. Just nicer to deal with 
printing and such. And instead of having to remember the factor, it's 
stored with the type.


More information about the Digitalmars-d mailing list