# Check Fixnum

**URL:** <https://rubytalk.org/t/check-fixnum/58897>\
**Category:** ruby-talk\
**Created:** [15 June 2010 15:43 UTC](https://rubytalk.org/t/check-fixnum/58897 "2010-06-15T15:43:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stanislav\_Orlenko](https://avatars.discourse-cdn.com/v4/letter/s/f19dbf/32.png) [@Stanislav\_Orlenko](https://rubytalk.org/u/Stanislav_Orlenko)\
**Post date:** [15 June 2010 15:43 UTC](https://rubytalk.org/t/check-fixnum/58897/1 "2010-06-15T15:43:59Z")

</div>

Hi  
I have Fixnum. I want to check does this value integer or float, i. e.  
has .xx in the trail or not. How can I check this?  
Thanks in advance

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

---

<div class="post-metadata">

**Author:** ![Brian\_Candler](https://avatars.discourse-cdn.com/v4/letter/b/5f9b8f/32.png) [@Brian\_Candler](https://rubytalk.org/u/Brian_Candler)\
**Post date:** [15 June 2010 15:49 UTC](https://rubytalk.org/t/check-fixnum/58897/2 "2010-06-15T15:49:24Z")

</div>

Stanislav Orlenko wrote:

> I have Fixnum. I want to check does this value integer or float, i. e.  
> has .xx in the trail or not. How can I check this?

"Fixnum" means "fixed point", or really "small integer": a Fixnum can  
never be a float.

$ irb --simple-prompt

> > 3.is\_a?(Fixnum)

=\> true

> > 3.0.is\_a?(Fixnum)

=\> false

> > 3.0.is\_a?(Integer)

=\> false

> > 3.0.is\_a?(Float)

=\> true

> > 3.0.is\_a?(Numeric)

=\> true

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

---

<div class="post-metadata">

**Author:** ![Eric\_MSP\_Veith](https://avatars.discourse-cdn.com/v4/letter/e/ecd19e/32.png) [@Eric\_MSP\_Veith](https://rubytalk.org/u/Eric_MSP_Veith)\
**Post date:** [15 June 2010 15:52 UTC](https://rubytalk.org/t/check-fixnum/58897/3 "2010-06-15T15:52:16Z")

</div>

Hey,

> Hi  
> I have Fixnum. I want to check does this value integer or float, i. e.  
> has .xx in the trail or not. How can I check this?  
> Thanks in advance

Mathematically by doing a modulo division by 1:

- ---%\<---  
irb(main):001:0\> i = 5  
=\> 5  
irb(main):002:0\> j = 5.2  
=\> 5.2  
irb(main):003:0\> j %1  
=\> 0.2  
irb(main):004:0\> i%1  
=\> 0  
- ---\>%---

HTH.  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Eric

> **···**
>
> On Tuesday 15 June 2010, Stanislav Orlenko \<orlenko.stas@gmail.com\> wrote:

---

<div class="post-metadata">

**Author:** ![Louis-Philippe](https://avatars.discourse-cdn.com/v4/letter/l/db5fbb/32.png) [@Louis-Philippe](https://rubytalk.org/u/Louis-Philippe)\
**Post date:** [15 June 2010 16:03 UTC](https://rubytalk.org/t/check-fixnum/58897/4 "2010-06-15T16:03:26Z")

</div>

check your reference...  
Fixnum are Integers, not float...  
you are probably mislead by Numeric... because Integer and Float are  
Numeric

a = 0.1  
a.class  
=\> Float

b = 1  
b.class  
=\> Fixnum

a.is\_a? Numeric  
=\> true

b.is\_a? Numeric  
=\> true

> **···**
>
> 2010/6/15 Stanislav Orlenko \<orlenko.stas@gmail.com\>
> 
> > Hi  
> > I have Fixnum. I want to check does this value integer or float, i. e.  
> > has .xx in the trail or not. How can I check this?  
> > Thanks in advance  
> > --  
> > Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).
