From: "trans. (T. Onoma)" Date: 2004-10-16T02:26:27+09:00 Subject: Re: Rounding to X digits On Friday 15 October 2004 11:14 am, Ara.T.Howard@noaa.gov wrote:|    jib:~/eg/ruby > cat truncate.rb|    class Float|      def truncate sd = 2|        i = self.to_i|        prec = 10 ** sd|        fraction = (i.zero? ? self : (self / i) - 1)|        i + (fraction * prec).to_i / prec.to_f|      end|    end||    p(0.1 * (134.45/0.1).truncate)                   #=> 134.4|    p((134.45 * (1/0.1)).truncate.to_f / (1/0.1))    #=> 134.4||    jib:~/eg/ruby > ruby truncate.rb|    134.4|    134.4 Sorry, I don't follow. Isn't that answer incorrect? The mid-point should round up, not down. At least, that's what I was taught in school. T.