From: Josselin Date: 2007-05-23T23:24:55+09:00 Subject: printing float to string with decimal rounding I am trying to print a float result in a string but I can get it right I get float numbers like : distance = 0.2568915421 , 1.2568910001, 20.3256941254 (8 decimals) I wrote d = (distance.*1000).round/1000.0 # to get something like 0.257 return "(- de 500m)" if d < 0.500 return "( - de 1km)" if d < 1.0 return "(env. " + d.to_s + " km)" if d > 1.0 i print "env. 1.257 km" I'd like to print "env. 1.2 km" shoudl I round it again ? or is there any DRY solution ? thanks joss