Opened 6 years ago

Closed 6 years ago

#5389 closed bug (invalid)

Floating point error

Reported by: Gabi Owned by:
Priority: normal Milestone:
Component: GHCi Version: 6.12.1
Keywords: floating point errors Cc:
Operating System: Linux Architecture: x86
Type of failure: Incorrect result at runtime Test Case: 9.6+4.8
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


I'm running GHC version 6.12.1 on Debian Squeeze. While using the interpreter, I started getting unexpected results in some floating point operations. I have run some tests to pinpoint the problem, and I got the following results:

0.6+0.8=1.4 but 9.6+4.8=14.399999999999999

0.8+5.4=6.2 but 10.8+5.4=16.200000000000003

Is there any way to fix this?

Change History (2)

comment:1 Changed 6 years ago by Gabi

Type of failure: None/UnknownIncorrect result at runtime

comment:2 Changed 6 years ago by igloo

Resolution: invalid
Status: newclosed

I'm afraid that's expected. You'll get the same results in other languages too.

Depending on what you're doing, you may want to use Data.Fixed or Data.Ratio instead.

Note: See TracTickets for help on using tickets.