Assert_equal not evaluating to TRUE

I have the following assert_equal in my unit test:

assert_equal 65000.0, do_calc

And get this Failure message back:

<65000.0> expected but was

How can that be ??? Has anybody seen this before?


On 12 Sep 2006, at 11:21, Joerg D. wrote:

How can that be ??? Has anybody seen this before?

You’re working with floats, which you can’t reliably compare with
==. Check out assert_in_delta instead.

if do_calc does floating-point math, there’s a chance that you have
floating-point errors. its neither your code nor ruby, but a problem
floating points and binary representation in general, since there are
numbers that cant be presented in binary, they are just rounded to be
approx. the right value. for more info on that, google is your friend,
i dont really know how to explain that in english :slight_smile:

2006/9/12, Joerg D. [email protected]:

Michael S. [email protected] - Gedanken lesen - Weltraum-Browsergame im Alpha-Stadium