opensubscriber
   Find in this group all groups
 
Unknown more information…

g : glasgow-haskell-users@haskell.org 10 July 2012 • 7:21PM -0400

Re: How to describe this bug?
by Aleksey Khudyakov

REPLY TO AUTHOR
 
REPLY TO GROUP




On Tue, Jul 10, 2012 at 3:06 PM, Sönke Hahn <shahn@cs.t...> wrote:
> I've attached the code. The code does not make direct use of
> unsafePerformIO. It uses QuickCheck, but I don't think, this is a
> QuickCheck bug. The used Eq-instance is the one for Float.
>
> I've only managed to reproduce this bug on 32-bit-linux with ghc-7.4.2
> when compiling with -O2.
>
It's expected behaviour with floats. Calculations in FPU are done in
maximul precision available.  If one evaluation result is kept in registers
and another has been moved to memory and rounded and move back to registers
number will be not the same indeed.

In short. Never compare floating point number for equality unless you
really know
what are you doing.

_______________________________________________
Glasgow-haskell-users mailing list
Glasgow-haskell-users@hask...
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Bookmark with:

Delicious   Digg   reddit   Facebook   StumbleUpon

Related Messages

opensubscriber is not affiliated with the authors of this message nor responsible for its content.