From: Eric Hodel Date: 2011-10-25T09:43:20+09:00 Subject: [ruby-core:40321] [ruby-trunk - Bug #5477][Rejected] to_f function / multiplication bug Issue #5477 has been updated by Eric Hodel. Status changed from Open to Rejected Yes, see also: http://wiki.github.com/rdp/ruby_tutorials_core/ruby-talk-faq#floats_imprecise http://en.wikipedia.org/wiki/Floating_point#Accuracy_problems ---------------------------------------- Bug #5477: to_f function / multiplication bug http://redmine.ruby-lang.org/issues/5477 Author: Noto Modungwa Status: Rejected Priority: Normal Assignee: Category: core Target version: 1.9.2 ruby -v: ruby 1.9.2p174 (2011-01-28 revision 30696) [x86_64-darwin10.6.0] This is posted on stack overflow but I thought I should report it here Hi I just ran into an issue where ruby's to_f function is giving me inconsistent results. ruby-1.9.2-head :026 > 8.45.to_f * 100 => 844.9999999999999 ruby-1.9.2-head :027 > 4.45.to_f * 100 => 445.0 ruby-1.9.2-head :028 > 4.35.to_f * 100 => 434.99999999999994 My workaround is to simply round the result this way ruby-1.9.2-head :029 > (4.35.to_f * 100).round => 435 After more playing around I realised that the issue might be with the multiplication operator "* 100" -- http://redmine.ruby-lang.org