From: Diogo Almeida Date: 2010-07-13T22:15:40+09:00 Subject: Re: Ruby 1.9.2 float precision Robert Klemme wrote: > 2010/7/13 Diogo Almeida : > > I question the validity of the test. Expecting a particular > formatting of a float number without giving a concrete format is at > least fragile (as you have discovered) - I would even call it wrong. > Different than for integers there is no common agreed way to convert > floats to strings so if you want a particular formatting you need to > make it part of the test. An alternative would be a regexp match > against \A4\.6+7\z > > irb(main):001:0> /\A4\.6+7\z/ =~ (14.0/3).to_s > => 0 Yes, I found it odd when I saw it myself. Though, since this was a recent change I figured someone could know how to fallback to the "old formatting", without having to use regex, or other alternative approaches. Best regards. -- Posted via http://www.ruby-forum.com/.