On Mon, Jul 03, 2017 at 05:38:56AM +0000, Era Scarecrow via Digitalmars-d-learn wrote: > On Monday, 3 July 2017 at 03:57:25 UTC, Basile B wrote: > > 6.251 has no perfect double representation. It's real value is: > > I almost wonder if a BCD, fixed length or alternative for floating > point should be an option... Either library, or a hook to change how > the FPU works since doubles are suppose to do 16-18 digits of perfect > simple floatingpoint for the purposes of money and the like without > relying on such imperfect transitions.
>From what I've heard, word on the street is to avoid using floating-point for money calculations, and use fixed-point arithmetic instead (i.e., basically ints / longs, with a built-in decimal point in a fixed position). Inexact representations of certain fractions of tens like the above are one reason for this. I don't think there's a way to change how the FPU works -- the hardware is coded that way and can't be changed. You'd have to build your own library or use an existing one for this purpose. T -- Food and laptops don't mix.