From: Bil Kleb Date: 2003-03-29T05:09:20+09:00 Subject: scanf failing(?) for floats read from a file I'm beginning to use scanf (thanks David, Hal, Noland, and Jason!) to read some floats. However, I am getting some bad data from it when using it to read data from a file. For example, simply varying the trailing spaces, require 'scanf' File.open 'temp', 'w' do |f| f.puts '0.0 1.23' f.puts '1.1 1.23 ' f.puts '2.2 1.23 ' end File.open 'temp' do |f| 6.times{ puts f.scanf '%f' } end produces, 0.0 1.23 1.1 0.23 2.2 23.0 Any ideas? Am I supposed to be using something else? This is for scanf 1.1.1 and ruby 1.7.2 (2002-05-29) and 1.6.8 (2003-03-26) on i686-linux. Thanks, -- Bil Kleb NASA Langley Research Center Hampton, Virginia, USA