Jim Freeze <jim / freeze.org> writes:

> On Tue, 20 Mar 2001, Hee-Sob Park wrote:
> 
> > I think it's difference in operator precedence.
> >
> > Try following code:
> >
> > p (2.4/0.2).to_i  # -> 12.0
> > p ((2.4/0.2).to_i) #-> 11
> >
> Can you explain this?
> I would call this a bug.

Remember that method calls take parameters in parentheses. The
examples probably make more sense it you remove the space after the
name of the method call ('p' in this case)

 p(2.4/0.2).to_i
    is equivalent to   (p(2.4/.2)).to_i
   
 p((2.4/0.2).to_i)


Why the difference? 2.4/0.2 isn't represented exactly as a binary
number, and to_i truncates floats.


Dave