From: Witold Baryluk Date: 2011-09-26T12:31:40+09:00 Subject: [ruby-core:39722] [Ruby 1.8 - Bug #5367][Open] Floating point number display problem Issue #5367 has been reported by Witold Baryluk. ---------------------------------------- Bug #5367: Floating point number display problem http://redmine.ruby-lang.org/issues/5367 Author: Witold Baryluk Status: Open Priority: Normal Assignee: Category: Target version: ruby -v: ruby 1.8.7 (2011-06-30 patchlevel 352) [i486-linux] Hi, I'm not really an Ruby user/developer, but noticed this with irb1.8 from Debian sid. irb(main):005:0> 9007199254740994.0 => 9.00719925474099e+15 irb(main):006:0> 9007199254740994.0 - 9.00719925474099e+15 => 4.0 It looks that Ruby do not convert floating point numbers to decimal/scientific notation correctly (preserving precisly value) by default. I think it is good behavior to preserve value 100% by default, as it can lead to nasty bugs otherwise. It is quite common bug in various libraries, and known correct (not just hacks) solutions can be find on the Internet. $ irb1.8 -v irb 0.9.5(05/04/13) $ dpkg -l ruby1.8 ii ruby1.8 1.8.7.352-2 Interpreter of object-oriented scripting language Ruby 1.8 $ uname Linux sredniczarny 3.0.0-1-686-pae #1 SMP Sat Aug 27 16:41:03 UTC 2011 i686 GNU/Linux $ cat /proc/cpuinfo | egrep 'model|flags|fpu' model : 13 model name : Intel(R) Pentium(R) M processor 1.73GHz fpu : yes fpu_exception : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov clflush dts acpi mmx fxsr sse sse2 ss tm pbe nx up bts est tm2 Thanks. -- http://redmine.ruby-lang.org