From: Jason Mayer Date: 2006-12-29T10:58:52+09:00 Subject: Re: Newbie: Looking for help rounding numbers ------=_Part_112930_29659901.1167357530793 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 12/28/06, Ja Bo wrote: > > I can't figure out how to round my answer from this short code that I > wrote. I was trying to use both 'format' and 'round' with no luck... > > Thank you all in advance!!! > > Code: > puts "Fahrenheit to Centigrade Conversion" > puts "-----------------------------------" > > puts "Input a temperature in Fahrenheit: " > STDOUT.flush > ftemp = gets.chomp.to_f > > ctemp = ( (ftemp - 32) / 1.8 ) > format( "%.2f", ctemp ) > > puts "" > puts ftemp.to_s + " F is " + ctemp.to_s + " C." > puts "" > > -- > Posted via http://www.ruby-forum.com/. > > I don't see what's wrong with round. puts ftemp.to_s + " F is " + ctemp.round.to_s + " C." output: Fahrenheit to Centigrade Conversion ----------------------------------- Input a temperature in Fahrenheit: 0 0.0 F is -18 C. ------=_Part_112930_29659901.1167357530793--