# Ruby doesn't know how to multiply

**URL:** <https://rubytalk.org/t/ruby-doesnt-know-how-to-multiply/38518>\
**Category:** ruby-talk\
**Created:** [21 June 2007 19:25 UTC](https://rubytalk.org/t/ruby-doesnt-know-how-to-multiply/38518 "2007-06-21T19:25:04Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![rjprado](https://avatars.discourse-cdn.com/v4/letter/r/dc4da7/32.png) [@rjprado](https://rubytalk.org/u/rjprado)\
**Post date:** [21 June 2007 19:25 UTC](https://rubytalk.org/t/ruby-doesnt-know-how-to-multiply/38518/1 "2007-06-21T19:25:04Z")

</div>

Hello,

Dear friends, today I have stumbled into a really weird problem. Try  
typing this on irb:

14.95 \* 0.6 == 8.97

Ruby says it's false!

I don't know if this is a bug. Please let me know. By the way i´m on  
ruby 1.8.5. I'll give it a try on 1.8.6 and let you know.

Thanks,  
Roberto Prado.

---

<div class="post-metadata">

**Author:** ![juan\_pedro\_merino](https://avatars.discourse-cdn.com/v4/letter/j/e95f7d/32.png) [@juan\_pedro\_merino](https://rubytalk.org/u/juan_pedro_merino)\
**Post date:** [21 June 2007 19:30 UTC](https://rubytalk.org/t/ruby-doesnt-know-how-to-multiply/38518/2 "2007-06-21T19:30:09Z")

</div>

I thingh that it is a bug

> **···**
>
> 2007/6/21, rjprado@gmail.com \<rjprado@gmail.com\>:
> 
> > Hello,
> > 
> > Dear friends, today I have stumbled into a really weird problem. Try  
> > typing this on irb:
> > 
> > 14.95 \* 0.6 == 8.97
> > 
> > Ruby says it's false!
> > 
> > I don't know if this is a bug. Please let me know. By the way i´m on  
> > ruby 1.8.5. I'll give it a try on 1.8.6 and let you know.
> > 
> > Thanks,  
> > Roberto Prado.
> 
> --  
> Juan Pedro Meriño Diaz  
> Ing de Sistema CURN

---

<div class="post-metadata">

**Author:** ![Gregory\_Seidman](https://avatars.discourse-cdn.com/v4/letter/g/eb9ed0/32.png) [@Gregory\_Seidman](https://rubytalk.org/u/Gregory_Seidman)\
**Post date:** [21 June 2007 19:31 UTC](https://rubytalk.org/t/ruby-doesnt-know-how-to-multiply/38518/3 "2007-06-21T19:31:46Z")

</div>

> Hello,
> 
> Dear friends, today I have stumbled into a really weird problem. Try  
> typing this on irb:
> 
> 14.95 \* 0.6 == 8.97
> 
> Ruby says it's false!
> 
> I don't know if this is a bug. Please let me know. By the way i?m on  
> ruby 1.8.5. I'll give it a try on 1.8.6 and let you know.

% irb

> > "%2.40f" % (14.95 \* 0.6)

=\> "8.9699999999999988631316227838397026062012"

> > "%2.40f" % 8.97

=\> "8.9700000000000006394884621840901672840118"

> **[Round-off error](https://en.wikipedia.org/wiki/Rounding_error)**
>
> In computing, a roundoff error, also called rounding error, is the difference between the result produced by a given algorithm using exact arithmetic and the result produced by the same algorithm using finite-precision, rounded arithmetic. Rounding errors are due to inexactness in the representation of real numbers and the arithmetic operations done with them. This is a form of quantization error. When using approximation equations or algorithms, especially when using finitely many di When a se...

> Thanks,  
> Roberto Prado.

--Greg

> **···**
>
> On Fri, Jun 22, 2007 at 04:25:04AM +0900, rjprado@gmail.com wrote:

---

<div class="post-metadata">

**Author:** ![Greg\_Brown1](https://avatars.discourse-cdn.com/v4/letter/g/258eb7/32.png) [@Greg\_Brown1](https://rubytalk.org/u/Greg_Brown1)\
**Post date:** [21 June 2007 19:33 UTC](https://rubytalk.org/t/ruby-doesnt-know-how-to-multiply/38518/4 "2007-06-21T19:33:02Z")

</div>

It's not a bug. It's the way floating point arithmetic works, and is  
true for \*most\* programming languages.

[http://docs.sun.com/source/806-3568/ncg\_goldberg.html](http://docs.sun.com/source/806-3568/ncg_goldberg.html)

> **···**
>
> On 6/21/07, rjprado@gmail.com \<rjprado@gmail.com\> wrote:
> 
> > Hello,
> > 
> > Dear friends, today I have stumbled into a really weird problem. Try  
> > typing this on irb:
> > 
> > 14.95 \* 0.6 == 8.97
> > 
> > Ruby says it's false!
> > 
> > I don't know if this is a bug. Please let me know. By the way i´m on  
> > ruby 1.8.5. I'll give it a try on 1.8.6 and let you know.

---

<div class="post-metadata">

**Author:** ![MenTaLguY1](https://avatars.discourse-cdn.com/v4/letter/m/97f17d/32.png) [@MenTaLguY1](https://rubytalk.org/u/MenTaLguY1)\
**Post date:** [21 June 2007 19:41 UTC](https://rubytalk.org/t/ruby-doesnt-know-how-to-multiply/38518/5 "2007-06-21T19:41:20Z")

</div>

This happens in all languages that use floating point to represent decimal numbers (you will get precisely the same result in C or Javascript or Perl, for instance). Floating-point arithmetic is only approximate, so the result does not \_exactly\_ equal 8.97, even though it is very close.

Because of this, when using floating-point arithmetic, testing for exact equality is impractical. The best you can do is test whether the result is within some interval (epsilon) of the expected result:

( ( 14.95 \* 0.6 ) - 8.97 ).abs \< 1e-6

(Here, we've chosen 1e-6 as our epsilon, which is arbitrary but probably "small enough" in this case. For mathematically intensive code, you may need to be more careful.)

Although floating-point is the default for Ruby, you do have the option of using a different representation of numbers for which arithmetic is exact, although it will not be as fast. One such option is the Rational class in Ruby's standard library, which represents numbers as fractions rather than floating-point numbers.

-mental

> **···**
>
> On Fri, 22 Jun 2007 04:25:04 +0900, "rjprado@gmail.com" \<rjprado@gmail.com\> wrote:
> 
> > Dear friends, today I have stumbled into a really weird problem. Try  
> > typing this on irb:
> > 
> > 14.95 \* 0.6 == 8.97
> > 
> > Ruby says it's false!

---

<div class="post-metadata">

**Author:** ![rjprado](https://avatars.discourse-cdn.com/v4/letter/r/dc4da7/32.png) [@rjprado](https://rubytalk.org/u/rjprado)\
**Post date:** [21 June 2007 19:55 UTC](https://rubytalk.org/t/ruby-doesnt-know-how-to-multiply/38518/6 "2007-06-21T19:55:11Z")

</div>

Yes, you are all right. It's a common problem. I have confirmed this  
by doing the same thing on java. Thank you all for your fast replies.

Greetings,  
Roberto Prado.

> **···**
>
> On Jun 21, 3:21 pm, "rjpr...@gmail.com" \<rjpr...@gmail.com\> wrote:
> 
> > Hello,
> > 
> > Dear friends, today I have stumbled into a really weird problem. Try  
> > typing this on irb:
> > 
> > 14.95 \* 0.6 == 8.97
> > 
> > Ruby says it's false!
> > 
> > I don't know if this is a bug. Please let me know. By the way i´m on  
> > ruby 1.8.5. I'll give it a try on 1.8.6 and let you know.
> > 
> > Thanks,  
> > Roberto Prado.

---

<div class="post-metadata">

**Author:** ![James\_Edward\_Gray\_II](https://avatars.discourse-cdn.com/v4/letter/j/ea5d25/32.png) [@James\_Edward\_Gray\_II](https://rubytalk.org/u/James_Edward_Gray_II)\
**Post date:** [21 June 2007 19:33 UTC](https://rubytalk.org/t/ruby-doesnt-know-how-to-multiply/38518/7 "2007-06-21T19:33:20Z")

</div>

It's not. It's a typical floating point error:

> **[Floating-point arithmetic](https://en.wikipedia.org/wiki/Floating_point)**
>
> In computing, floating-point arithmetic (FP) is arithmetic that represents subsets of real numbers using an integer with a fixed precision, called the significand, scaled by an integer exponent of a fixed base.
> Numbers of this form are called floating-point numbers.: 3 : 10 
> For example, 12.345 is a floating-point number in base ten with five digits of precision:
> However, unlike 12.345, 12.3456 is not a floating-point number in base ten with five digits of precision—it needs six digits of pre...

James Edward Gray II

> **···**
>
> On Jun 21, 2007, at 2:30 PM, juan pedro meriño wrote:
> 
> > I thingh that it is a bug

---

<div class="post-metadata">

**Author:** ![juan\_pedro\_merino](https://avatars.discourse-cdn.com/v4/letter/j/e95f7d/32.png) [@juan\_pedro\_merino](https://rubytalk.org/u/juan_pedro_merino)\
**Post date:** [21 June 2007 19:46 UTC](https://rubytalk.org/t/ruby-doesnt-know-how-to-multiply/38518/8 "2007-06-21T19:46:40Z")

</div>

thank you!

> **···**
>
> 2007/6/21, MenTaLguY \<mental@rydia.net\>:
> 
> > On Fri, 22 Jun 2007 04:25:04 +0900, "rjprado@gmail.com" \<rjprado@gmail.com\> \> wrote:  
> > \> Dear friends, today I have stumbled into a really weird problem. Try  
> > \> typing this on irb:  
> > \>  
> > \> 14.95 \* 0.6 == 8.97  
> > \>  
> > \> Ruby says it's false!
> > 
> > This happens in all languages that use floating point to represent decimal  
> > numbers (you will get precisely the same result in C or Javascript or Perl,  
> > for instance). Floating-point arithmetic is only approximate, so the result  
> > does not \_exactly\_ equal 8.97, even though it is very close.
> > 
> > Because of this, when using floating-point arithmetic, testing for exact  
> > equality is impractical. The best you can do is test whether the result is  
> > within some interval (epsilon) of the expected result:
> > 
> > ( ( 14.95 \* 0.6 ) - 8.97 ).abs \< 1e-6
> > 
> > (Here, we've chosen 1e-6 as our epsilon, which is arbitrary but probably  
> > "small enough" in this case. For mathematically intensive code, you may  
> > need to be more careful.)
> > 
> > Although floating-point is the default for Ruby, you do have the option of  
> > using a different representation of numbers for which arithmetic is exact,  
> > although it will not be as fast. One such option is the Rational class in  
> > Ruby's standard library, which represents numbers as fractions rather than  
> > floating-point numbers.
> > 
> > -mental
> 
> --  
> Juan Pedro Meriño Diaz  
> Ing de Sistema CURN

---

<div class="post-metadata">

**Author:** ![Nasir\_Khan](https://avatars.discourse-cdn.com/v4/letter/n/5daacb/32.png) [@Nasir\_Khan](https://rubytalk.org/u/Nasir_Khan)\
**Post date:** [21 June 2007 19:50 UTC](https://rubytalk.org/t/ruby-doesnt-know-how-to-multiply/38518/9 "2007-06-21T19:50:58Z")

</div>

And if you are using test/unit then use the assertion method  
assert\_in\_delta()

- nasir

> **···**
>
> On 6/21/07, MenTaLguY \<mental@rydia.net\> wrote:
> 
> > On Fri, 22 Jun 2007 04:25:04 +0900, "rjprado@gmail.com" \<rjprado@gmail.com\> \> wrote:  
> > \> Dear friends, today I have stumbled into a really weird problem. Try  
> > \> typing this on irb:  
> > \>  
> > \> 14.95 \* 0.6 == 8.97  
> > \>  
> > \> Ruby says it's false!
> > 
> > This happens in all languages that use floating point to represent decimal  
> > numbers (you will get precisely the same result in C or Javascript or Perl,  
> > for instance). Floating-point arithmetic is only approximate, so the result  
> > does not \_exactly\_ equal 8.97, even though it is very close.
> > 
> > Because of this, when using floating-point arithmetic, testing for exact  
> > equality is impractical. The best you can do is test whether the result is  
> > within some interval (epsilon) of the expected result:
> > 
> > ( ( 14.95 \* 0.6 ) - 8.97 ).abs \< 1e-6
> > 
> > (Here, we've chosen 1e-6 as our epsilon, which is arbitrary but probably  
> > "small enough" in this case. For mathematically intensive code, you may  
> > need to be more careful.)
> > 
> > Although floating-point is the default for Ruby, you do have the option of  
> > using a different representation of numbers for which arithmetic is exact,  
> > although it will not be as fast. One such option is the Rational class in  
> > Ruby's standard library, which represents numbers as fractions rather than  
> > floating-point numbers.
> > 
> > -mental

---

<div class="post-metadata">

**Author:** ![Lloyd\_Linklater](https://avatars.discourse-cdn.com/v4/letter/l/919ad9/32.png) [@Lloyd\_Linklater](https://rubytalk.org/u/Lloyd_Linklater)\
**Post date:** [21 June 2007 20:57 UTC](https://rubytalk.org/t/ruby-doesnt-know-how-to-multiply/38518/10 "2007-06-21T20:57:48Z")

</div>

> Yes, you are all right. It's a common problem. I have confirmed this  
> by doing the same thing on java. Thank you all for your fast replies.

I tried this in Delphi, smalltalk and oracle SQL and got the correct  
result.

C# and visual C++ seem to it to be false.

This is most perplexing.

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Shot\_Piotr\_Szotkowsk](https://avatars.discourse-cdn.com/v4/letter/s/c5a1d2/32.png) [@Shot\_Piotr\_Szotkowsk](https://rubytalk.org/u/Shot_Piotr_Szotkowsk)\
**Post date:** [24 June 2007 13:26 UTC](https://rubytalk.org/t/ruby-doesnt-know-how-to-multiply/38518/11 "2007-06-24T13:26:57Z")

</div>

MenTaLguY:

> The best you can do is test whether the result is  
> within some interval (epsilon) of the expected result:

> ( ( 14.95 \* 0.6 ) - 8.97 ).abs \< 1e-6

> (Here, we've chosen 1e-6 as our epsilon, which is arbitrary but  
> probably "small enough" in this case. For mathematically intensive  
> code, you may need to be more careful.)

Any particular reason against using Float::EPSILON here? 🙂

Maybe Float#== could simply be extended to consider the above? That  
would most probably open another can of worms, though, and extending  
Float#\<=\> would open yet another, I guess.

-- Shot

> **···**
>
> --  
> I'm not much of a kernel hacker, but a quick (and not very efficient,  
> granted) fix could be to make the offset an extern variable, yes?  
> That would force the compiler to fall back on the basic "your gun,  
> your foot, your choice" memory model. -- jtv, LKML

---

<div class="post-metadata">

**Author:** ![juan\_pedro\_merino](https://avatars.discourse-cdn.com/v4/letter/j/e95f7d/32.png) [@juan\_pedro\_merino](https://rubytalk.org/u/juan_pedro_merino)\
**Post date:** [21 June 2007 19:40 UTC](https://rubytalk.org/t/ruby-doesnt-know-how-to-multiply/38518/12 "2007-06-21T19:40:29Z")

</div>

You are rigth James, but you can better reponse why is a floating point  
error?

---

<div class="post-metadata">

**Author:** ![Yukihiro\_Matsumoto2](https://avatars.discourse-cdn.com/v4/letter/y/b9e5f3/32.png) [@Yukihiro\_Matsumoto2](https://rubytalk.org/u/Yukihiro_Matsumoto2)\
**Post date:** [22 June 2007 00:07 UTC](https://rubytalk.org/t/ruby-doesnt-know-how-to-multiply/38518/13 "2007-06-22T00:07:09Z")

</div>

Hi,

> **···**
>
> In message "Re: Ruby doesn't know how to multiply" on Fri, 22 Jun 2007 05:57:48 +0900, Lloyd Linklater \<lloyd@2live4.com\> writes:
> 
> > I tried this in Delphi, smalltalk and oracle SQL and got the correct  
> > result.
> 
> Interesting. There are a few ways to get the "correct" result.
> 
> &nbsp;&nbsp;\* fixed point number  
> &nbsp;&nbsp;\* base 10 floating numbers  
> &nbsp;&nbsp;\* comparison with epsilon
> 
> Does anyone know how these languages get the correct result?
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;matz.

---

<div class="post-metadata">

**Author:** ![Stefan\_Rusterholz](https://avatars.discourse-cdn.com/v4/letter/s/e495f1/32.png) [@Stefan\_Rusterholz](https://rubytalk.org/u/Stefan_Rusterholz)\
**Post date:** [24 June 2007 16:52 UTC](https://rubytalk.org/t/ruby-doesnt-know-how-to-multiply/38518/14 "2007-06-24T16:52:07Z")

</div>

Shot (Piotr Szotkowski) wrote:

> MenTaLguY:
> 
> > The best you can do is test whether the result is  
> > within some interval (epsilon) of the expected result:
> 
> > ( ( 14.95 \* 0.6 ) - 8.97 ).abs \< 1e-6
> 
> > (Here, we've chosen 1e-6 as our epsilon, which is arbitrary but  
> > probably "small enough" in this case. For mathematically intensive  
> > code, you may need to be more careful.)
> 
> Any particular reason against using Float::EPSILON here? 🙂
> 
> Maybe Float#== could simply be extended to consider the above? That  
> would most probably open another can of worms, though, and extending  
> Float#\<=\> would open yet another, I guess.
> 
> -- Shot

I think Float#== as it is is fine. Arguably it could use delta  
comparison with Float::EPSILON and leave the exact comparison to eql?  
But I'd like it if Float#in\_delta(other, delta=Float::EPSILON) was in  
core (personally I add it in my libs as Numeric#in\_delta).

Regards  
Stefan

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Adriano\_Ferreira](https://avatars.discourse-cdn.com/v4/letter/a/a3d4f5/32.png) [@Adriano\_Ferreira](https://rubytalk.org/u/Adriano_Ferreira)\
**Post date:** [21 June 2007 19:49 UTC](https://rubytalk.org/t/ruby-doesnt-know-how-to-multiply/38518/15 "2007-06-21T19:49:31Z")

</div>

Some numbers (like 0.1) cannot be represented exactly in binary with a  
finite number of bits (because 0.1[base 10] =  
0.0001100110011001100110011...[base 2]) and when they are represented  
(as it happens with floating point representations), they lose  
precision. So you must not test floating point for equality but always  
rely on some tolerance and use an expression like MenTaLguY showed:

( 14.95 \* 0.6 - 8.97 ).abs \< tol

where tol depends on your application.

> **···**
>
> On 6/21/07, juan pedro meriño \<juapdiaz@gmail.com\> wrote:
> 
> > You are rigth James, but you can better reponse why is a floating point  
> > error?

---

<div class="post-metadata">

**Author:** ![MenTaLguY1](https://avatars.discourse-cdn.com/v4/letter/m/97f17d/32.png) [@MenTaLguY1](https://rubytalk.org/u/MenTaLguY1)\
**Post date:** [21 June 2007 19:49 UTC](https://rubytalk.org/t/ruby-doesnt-know-how-to-multiply/38518/16 "2007-06-21T19:49:58Z")

</div>

Not all numbers can be represented by an arbitrarily small number of digits, and floating-point numbers only have so many digits available (for Ruby, 53 binary digits, which is about 16 decimal digits). In this case, the computation required more than 53 bits, so the result was approximate.

-mental

> **···**
>
> On Fri, 22 Jun 2007 04:40:29 +0900, "juan pedro meriño" \<juapdiaz@gmail.com\> wrote:
> 
> > You are rigth James, but you can better reponse why is a floating point  
> > error?

---

<div class="post-metadata">

**Author:** ![Michael\_W\_Ryder1](https://avatars.discourse-cdn.com/v4/letter/m/8e7dd6/32.png) [@Michael\_W\_Ryder1](https://rubytalk.org/u/Michael_W_Ryder1)\
**Post date:** [22 June 2007 00:45 UTC](https://rubytalk.org/t/ruby-doesnt-know-how-to-multiply/38518/17 "2007-06-22T00:45:06Z")

</div>

Yukihiro Matsumoto wrote:

> Hi,
> 
> \>I tried this in Delphi, smalltalk and oracle SQL and got the correct \>result.
> 
> Interesting. There are a few ways to get the "correct" result.
> 
> &nbsp;&nbsp;\* fixed point number  
> &nbsp;&nbsp;\* base 10 floating numbers  
> &nbsp;&nbsp;\* comparison with epsilon
> 
> Does anyone know how these languages get the correct result?
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;matz.

A simple way to get the correct figure is to do what is used often with currency to prevent these types of errors. If I enter 'puts 1495.0\*6.0/1000.0' I get 8.97. The only thing necessary is to keep track of the number of decimal points.

> **···**
>
> > In message "Re: Ruby doesn't know how to multiply" \> on Fri, 22 Jun 2007 05:57:48 +0900, Lloyd Linklater \<lloyd@2live4.com\> writes:

---

<div class="post-metadata">

**Author:** ![KUBO\_Takehiro](https://avatars.discourse-cdn.com/v4/letter/k/3be4f8/32.png) [@KUBO\_Takehiro](https://rubytalk.org/u/KUBO_Takehiro)\
**Post date:** [22 June 2007 05:17 UTC](https://rubytalk.org/t/ruby-doesnt-know-how-to-multiply/38518/18 "2007-06-22T05:17:32Z")

</div>

Hi,

> \>I tried this in Delphi, smalltalk and oracle SQL and got the correct  
> \>result.
> 
> Interesting. There are a few ways to get the "correct" result.
> 
> &nbsp;&nbsp;\* fixed point number  
> &nbsp;&nbsp;\* base 10 floating numbers  
> &nbsp;&nbsp;\* comparison with epsilon

Oracle uses base 100 floating numbers.  
[http://download-west.oracle.com/docs/cd/B19306\_01/appdev.102/b14250/oci03typ.htm#sthref431](http://download-west.oracle.com/docs/cd/B19306_01/appdev.102/b14250/oci03typ.htm#sthref431)

> **···**
>
> On 6/22/07, Yukihiro Matsumoto \<matz@ruby-lang.org\> wrote:
> 
> > Does anyone know how these languages get the correct result?

---

<div class="post-metadata">

**Author:** ![Rick\_DeNatale1](https://avatars.discourse-cdn.com/v4/letter/r/bbce88/32.png) [@Rick\_DeNatale1](https://rubytalk.org/u/Rick_DeNatale1)\
**Post date:** [22 June 2007 19:18 UTC](https://rubytalk.org/t/ruby-doesnt-know-how-to-multiply/38518/19 "2007-06-22T19:18:02Z")

</div>

matz,

I don't know which Smalltalk he used, but I just tried it in Squeak  
and it evalutes to false, just like in Ruby.

> **···**
>
> On 6/21/07, Yukihiro Matsumoto \<matz@ruby-lang.org\> wrote:
> 
> > Hi,
> > 
> > In message "Re: Ruby doesn't know how to multiply" \> on Fri, 22 Jun 2007 05:57:48 +0900, Lloyd Linklater \<lloyd@2live4.com\> writes:
> > 
> > \>I tried this in Delphi, smalltalk and oracle SQL and got the correct  
> > \>result.
> > 
> > Interesting. There are a few ways to get the "correct" result.
> > 
> > &nbsp;&nbsp;\* fixed point number  
> > &nbsp;&nbsp;\* base 10 floating numbers  
> > &nbsp;&nbsp;\* comparison with epsilon
> > 
> > Does anyone know how these languages get the correct result?
> 
> --  
> Rick DeNatale
> 
> My blog on Ruby  
> [http://talklikeaduck.denhaven2.com/](http://talklikeaduck.denhaven2.com/)

---

<div class="post-metadata">

**Author:** ![Greg\_Brown1](https://avatars.discourse-cdn.com/v4/letter/g/258eb7/32.png) [@Greg\_Brown1](https://rubytalk.org/u/Greg_Brown1)\
**Post date:** [24 June 2007 17:46 UTC](https://rubytalk.org/t/ruby-doesnt-know-how-to-multiply/38518/20 "2007-06-24T17:46:29Z")

</div>

I'd prefer in\_delta?, but I think this is a great idea. Maybe you  
should submit an RCR?

> **···**
>
> On 6/24/07, Stefan Rusterholz \<apeiros@gmx.net\> wrote:
> 
> > I think Float#== as it is is fine. Arguably it could use delta  
> > comparison with Float::EPSILON and leave the exact comparison to eql?  
> > But I'd like it if Float#in\_delta(other, delta=Float::EPSILON) was in  
> > core (personally I add it in my libs as Numeric#in\_delta).

[Next page](https://rubytalk.org/t/ruby-doesnt-know-how-to-multiply/38518.md?page=2)
