From: Jan Hendrickx Date: 2011-12-16T22:22:18+09:00 Subject: Re: Rounding error? WOW! You guys are realy fast :))) Vimal R. wrote in post #1037007: > I use Ruby 1.8.7. What version are you using? I'm using Ruby 1.9.3; downloaded it yesterday, so I suppose that's the latest stable version. Peter Vandenabeele wrote in post #1037008: > [Dutch: Dag Jan, welkom op de lijst] [Dutch: Hoi Peter, bedankt voor de verwelkoming :)] > Try to use BigDecimal. > http://www.ruby-doc.org/stdlib-1.9.3/libdoc/bigdecimal/rdoc/BigDecimal.html I changed the test-program like this: require 'bigdecimal' print("Length: ") s = gets() length = BigDecimal.new(s) print("Width: ") s = gets() width = BigDecimal.new(s) surface = length * width puts("Surface = #{length.to_f} x #{width.to_f} = #{surface.to_f}") It works fine now, but, well... I don't think it's very 'elegant'... I haven't had the time yet to read the page on BigDecimal, but I'll do that right now. Mike Stok wrote in post #1037010: > It you're interested in some reading about floating point then > http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html is worth > looking at. I'll go and have a look at that too... Greetings, and thanks to all! Janosik. -- Posted via http://www.ruby-forum.com/.