From: Stanislav Orlenko on
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/.

From: Brian Candler on
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/.

From: Eric MSP Veith on
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hey,

On Tuesday 15 June 2010, Stanislav Orlenko <orlenko.stas(a)gmail.com> wrote:
> 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.
Eric
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkwXoaUACgkQhS0drJ3goJLPgwCfbiFIMLRWNkskgnOSRAS6MNLC
vbkAnAgG5EJskR+JwijDs3HRvV2Iz+AH
=DVcg
-----END PGP SIGNATURE-----

From: Louis-Philippe on
[Note: parts of this message were removed to make it a legal post.]

2010/6/15 Stanislav Orlenko <orlenko.stas(a)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/.
>
>
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