Using assert_in_delta for floats with extended notation

Hi all,

For comparing floats I normally do something like this:

assert_in_delta(‘100.324’, ‘100.32’, 0.01)

However, for extended notation it breaks down:

assert_in_delta(1.34341429278853e+15,
18446744073709551616.quo(13731.24), 1.0)

That gives me a failure. What’s the proper way to test this?

Thanks,

Dan

On Jun 11, 5:32 pm, “Jano S.” [email protected] wrote:

However, for extended notation it breaks down:
assert_in_delta(1.34341429278853e+15, 18446744073709551616.quo(13731.24), 2.0)

works. (the difference is 1.75)

Jano

Thanks. I suck.

Dan

On 6/10/07, Daniel B. [email protected] wrote:

That gives me a failure. What’s the proper way to test this?

Thanks,

Dan

assert_in_delta(1.34341429278853e+15,
18446744073709551616.quo(13731.24), 2.0)

works. (the difference is 1.75)

Jano

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs