From: "Daniel G." Date: 2010-09-10T08:45:07+09:00 Subject: Re: rounding UP by 0.05 --001485f85a94d35d8f048fdc3720 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable I couldn't catch you that much, but I tried something like: (0.5625*10).ceil.to_f/10 # =3D> 0.6 That will round the number always up. I don't know if that would help you. Daniel Gayt=E1n 2010/9/9 Bharat Ruparel > I am almost there but not quite. I need to round UP the computed tax > amount to the nearest 5 cents (or $ 0.05). I have gotten to the point > where I can round (up or down) to the nearest 5 cents. Here is my > funtion: > > # computer the tax for each item given quantity, price, and percent tax > def compute_tax(quantity, price, percent_tax) > raw_value =3D (quantity * price * (percent_tax/100.0)) > rounded_value =3D (raw_value * 20).round / 20.0 > rounded_value > end > > This does not work for the cases where the computation of raw_value > works out to something like 0.5625 for example. The function shown > above returns 0.55. I would like it to return 0.60 in such cases. > Cannot figure this out. > > Appreciate any help in advance. > > Thanks. > > Bharat > -- > Posted via http://www.ruby-forum.com/. > > --001485f85a94d35d8f048fdc3720--