
On Wednesday 16 January 2013, 15:25:15, ivan dragolov wrote:
9.3 - (2 * 4.5) => 0.3000000000000007
I expected 0.3
?
Prelude Text.FShow.RealFloat> FD 9.3 9.300000000000000710542735760100185871124267578125 The closest Double to 9.3 is somewhat larger than 9.3. Since the first two significant digits are enough to distinguish it from the next smaller number, only those are delivered by the Show instance. If you subtract 9 from that, you get, unsurprisingly, Prelude Text.FShow.RealFloat> it - 9 0.300000000000000710542735760100185871124267578125 which is not the closest Double value to 0.3 (in fact, there are 12 Double values between that and the closest Double to 0.3). To distinguish that number from its neighbours, 16 significant digits are necessary, hence so many are displayed.