Hi,
I’m new to this group but have used Ruby for quite a while now (it’s a
great language by the way). In one of my methods I intend to divide a
Fixnum by a second Fixnum. I’d expected a Fixnum result but get Float back.
Can anyone give me an idea of what’s wrong? The code looks like this:
puts @m.class
puts d.class
puts @m
puts d
@m /= d
puts @m.class
puts d.class
puts @m
puts d
and the output is:
Fixnum
Fixnum
8
1
Float
Fixnum
8.0
1
Yours, Tore Haug-Warberg
I can’t replicate your output. It works correctly for me.
I am using Ruby 1.8.0, which version do you have?
···
On Fri, Jun 20, 2003 at 01:18:33AM +0900, Tore Haug-Warberg wrote:
Hi,
I’m new to this group but have used Ruby for quite a while now (it’s a
great language by the way). In one of my methods I intend to divide a
Fixnum by a second Fixnum. I’d expected a Fixnum result but get Float back.
Can anyone give me an idea of what’s wrong? The code looks like this:
puts @m.class
puts d.class
puts @m
puts d
@m /= d
puts @m.class
puts d.class
puts @m
puts d
and the output is:
Fixnum
Fixnum
8
1
Float
Fixnum
8.0
1
Yours, Tore Haug-Warberg
Daniel Carrera | OpenPGP fingerprint:
Graduate TA, Math Dept | 6643 8C8B 3522 66CB D16C D779 2FDD 7DAC 9AF7 7A88
UMD (301) 405-5137 | http://www.math.umd.edu/~dcarrera/pgp.html
I can’t replicate your result either. Is there something else going on
in related code?
···
On Thursday, June 19, 2003, at 12:22 PM, Daniel Carrera wrote:
[snip]
I can’t replicate your output. It works correctly for me.
I am using Ruby 1.8.0, which version do you have?
[snip]
Yes, I’ve loaded a module I did’nt know about. The problem was (of course)
evil operator overlading. Thanks for your help.
Tore Haug-Warberg
···
At 02:07 20.06.03 +0900, you wrote:
On Thursday, June 19, 2003, at 12:22 PM, Daniel Carrera wrote:
[snip]
I can’t replicate your output. It works correctly for me.
I am using Ruby 1.8.0, which version do you have?
[snip]
I can’t replicate your result either. Is there something else going on in
related code?