get fraction part of a decimal number

I am not sure if it is the easiest way to do it - but you can simply split the number using "." character - like this:

number = 1.23
parts = number.to_s.split(".")
result = parts.count > 1 ? parts[1].to_s : 0

Try to use modulo method:

1.23.modulo(1) => 0.23

Read more here: http://www.ruby-doc.org/core-1.9.3/Numeric.html#method-i-modulo

Or you can convert float to integer and substract it from original float value.

1.23 - 1.23.to_i => 0.23

n = 1.23

n.modulo(1)
=> 0.22999999999999998

n - n.to_i
=> 0.22999999999999998

Recommended read http://floating-point-gui.de/