From: Tim McIntyre Date: 2007-11-20T06:05:10+09:00 Subject: float math? --Apple-Mail-54-303263439 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed hey all, I've got a delimited file with lines like so... 1234^2007-11-17^4321^Peter Pan^123 test st^^portland^ir^97101^US^^^Statement 34567^87.92^Statement for 2007-11-17 quick script to total col 13 require 'csv' file = "myFile.txt" total = 0.0 CSV.open(file, "r", '^') do |row| print "#{total} + " total += row[13].to_f puts "#{row[13]} = #{total}" end output: ... 2415.06 + 20.99 = 2436.05 ... ... 6704.58 + 87.92 = 6792.5 6792.5 + 75.0 = 6867.5 6867.5 + 15.98 = 6883.48 <= so far so good! 6883.48 + 15.99 = 6899.46999999999 <= uhh oh.. what happened? 6899.46999999999 + 50.0 = 6949.46999999999 6949.46999999999 + 32.0 = 6981.46999999999 ... ... Why do all the extra decimal places all of the sudden come into play? Thanks for your time! Tim --Apple-Mail-54-303263439--