From: Michael Morin Date: 2008-12-19T11:53:41+09:00 Subject: Re: about Float Kyung won Cheon wrote: > a = 1333.3339999999964 > b = 1333.3339999999965 > c = 1333.334 > > puts a # 1333.334 > puts b # 1333.334 > puts c # 1333.334 > > puts a == b # => false > puts a == c # => false > puts b == c # => false > > ######################################################### > # HELP ME^^ > # > # How can I see 'real value' of Float object(a, b, c) ? > ######################################################### Comparing floating point numbers is usually not a very good idea. They're only approximations of the real number you're trying to represent. For that reason, when printing floating point numbers, it's useful to specify with what precision you want to print them. This usually involves some sort of format string. The sprintf example works, but I prefer something like this. a = 6.232523 puts ("%.3f" % a) -- Michael Morin Guide to Ruby http://ruby.about.com/ Become an About.com Guide: beaguide.about.com About.com is part of the New York Times Company