Help us understand the problem. What is going on with this article?

[Ruby]単純な計算結果がおかしい

More than 3 years have passed since last update.

どうでもいい話ですが、Ubuntu で ruby 1.9.3p484 使ってて単純な計算結果が変であることに気づく。何で?丸め誤差?

xxxxx@titan:~$ uname -a
Linux titan 3.13.0-74-generic #118-Ubuntu SMP Thu Dec 17 22:52:02 UTC 2015 i686 i686 i686 GNU/Linux
xxxxx@titan:~$ ruby -v
ruby 1.9.3p484 (2013-11-22 revision 43786) [i686-linux]
xxxxx@titan:~$ ruby -e 'puts 1.1*2.2'
2.4200000000000004
xxxxx@titan:~$ ruby -e 'puts 1.1*2.2*3.3'
7.986000000000001
xxxxx@titan:~$ 
hikanda
Linuxカーネルの中を見たり触ったりする関係で、いろいろカーネルの仕組みを覚えたり学んだりするので、オッと思ったことを書き綴ってみようと思います。
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away