Regarding multiplication, behavior of ruby is that 24.0 * 0.1
is not 2.4
. Why does this happen?
24.0 * 0.1
# => 2.4000000000000004
Regarding multiplication, behavior of ruby is that 24.0 * 0.1
is not 2.4
. Why does this happen?
24.0 * 0.1
# => 2.4000000000000004
Only very few numbers can be represented precisely in floating point arithmetic.
See http://en.wikipedia.org/wiki/Floating_point for more details.