From: Hassan Schroeder Date: 2012-12-10T01:54:38+09:00 Subject: Re: Conditional Loop question On Sun, Dec 9, 2012 at 8:11 AM, Ivan S. wrote: > can someone explain the behaviour of this simple loop that doesnt stop > in 1.13. > >>> x =1.12 > => 1.12 >>> loop do > ?> x=x+0.01 >>> break if (x==1.13 || x > 1.19) 1.9.3 (main):0 > 1.13 == 1.13 => true 1.9.3 (main):0 > 1.13 == (1.12 + 0.01) => false 1.9.3 (main):0 > 1.12 + 0.01 => 1.1300000000000001 1.9.3 (main):0 > BigDecimal.new("1.13") == ( BigDecimal.new("1.12") + BigDecimal("0.01") ) => true Floating Point strikes again :-) -- Hassan Schroeder ------------------------ hassan.schroeder@gmail.com http://about.me/hassanschroeder twitter: @hassan