From: dblack@... Date: 2003-03-29T05:53:54+09:00 Subject: Re: scanf failing(?) for floats read from a file Hi -- On Sat, 29 Mar 2003, Bil Kleb wrote: > 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? Yes. Rewind to scanf-1.1.0 :-( I fear I've introduced a glitch somewhere in 1.1.1. (It passes all the tests but apparently we need some more tests :-) This is my fault -- I did what I thought was some successful refactoring but apparently it wasn't entirely. If you need me to I can mail you 1.1.0, and I'll talk to Hal about putting it back on the site. Thanks for reporting it -- David -- David Alan Black home: dblack@superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav