# Weird Fixnum division

**URL:** <https://rubytalk.org/t/weird-fixnum-division/6466>\
**Category:** ruby-talk\
**Created:** [19 June 2003 16:18 UTC](https://rubytalk.org/t/weird-fixnum-division/6466 "2003-06-19T16:18:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tore\_Haug-Warberg](https://avatars.discourse-cdn.com/v4/letter/t/9fc348/32.png) [@Tore\_Haug-Warberg](https://rubytalk.org/u/Tore_Haug-Warberg)\
**Post date:** [19 June 2003 16:18 UTC](https://rubytalk.org/t/weird-fixnum-division/6466/1 "2003-06-19T16:18:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Daniel\_Carrera](https://avatars.discourse-cdn.com/v4/letter/d/c67d28/32.png) [@Daniel\_Carrera](https://rubytalk.org/u/Daniel_Carrera)\
**Post date:** [19 June 2003 16:22 UTC](https://rubytalk.org/t/weird-fixnum-division/6466/2 "2003-06-19T16:22:42Z")

</div>

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](http://www.math.umd.edu/~dcarrera/pgp.html)

---

<div class="post-metadata">

**Author:** ![Mark\_Wilson](https://avatars.discourse-cdn.com/v4/letter/m/a3d4f5/32.png) [@Mark\_Wilson](https://rubytalk.org/u/Mark_Wilson)\
**Post date:** [19 June 2003 17:07 UTC](https://rubytalk.org/t/weird-fixnum-division/6466/3 "2003-06-19T17:07:38Z")

</div>

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]

---

<div class="post-metadata">

**Author:** ![Tore\_Haug-Warberg](https://avatars.discourse-cdn.com/v4/letter/t/9fc348/32.png) [@Tore\_Haug-Warberg](https://rubytalk.org/u/Tore_Haug-Warberg)\
**Post date:** [20 June 2003 06:53 UTC](https://rubytalk.org/t/weird-fixnum-division/6466/4 "2003-06-20T06:53:50Z")

</div>

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?
