Decimal Floating Point types.

Era Scarecrow rtcvb32 at yahoo.com
Mon Oct 29 18:15:11 PDT 2012


On Monday, 29 October 2012 at 22:49:16 UTC, H. S. Teoh wrote:
> I thought it was better to use fixed-point with currency? Or at 
> least, so I've heard.

  Depends on the application. Years ago (10?) I made a little 
interest calculating C program, floating point and rounding gave 
me so many issues with 1-2 pennies off that I went with an int 
and just took the bottom 2 digits as pennies. Worked far better 
than fighting with the floating point issues.

  I do remember somewhere that the double could be used to 
accurately calculate money up to 18 digits, but I can't remember 
if there was a specific mode you had to tell the FPU.


More information about the Digitalmars-d mailing list