Something still wrong there, Bill. plug in 8.55 and you get 8.00. I think Albert's approach is right and was working on a single rather colmplex expression to do the same thing, but then I thought to myself, "Self, why are you doing this?" I mean why would anyone want to purposely detune data like that? Computers and R:base inherently are accurate to a penny withhout any effort on our part... Plus rounding can introduce a compounding of errors in certain cases. Envision a carpenter trading in his 1/16 inch graduated tape for one with 1/2 inch graduations.
On Tue, Aug 30, 2011 at 3:44 AM, Bill Downall < [email protected]> wrote: > Sorry, Tom, I didn't think it through. Try this: > > Add .25 to your value, then take the (truncated) integer of the result, and > divide that by .50. That gives you the number of 50-cents in your answer, so > multiply all that by .50, (or divide by 2). > > (.50 * (int((currvalue + .25) / .50 )) > > Bill > > On Mon, Aug 29, 2011 at 7:40 PM, TOM HART <[email protected]> wrote: > >> Bill, >> I tried 7.46 and it returned 7.4, but I want 7.5 >> Tom >> >> ------------------------------ >> *From:* Bill Downall <[email protected]> >> *To:* RBASE-L Mailing List <[email protected]> >> *Sent:* Mon, August 29, 2011 4:59:29 PM >> *Subject:* [RBASE-L] - Re: Rounding >> >> Tom, >> >> Multiply by fifty, find the nearest integer, then divide by 50. >> >> ((nint((50 * currencycolumn)) / 50) >> >> Bill >> >> On Mon, Aug 29, 2011 at 5:17 PM, TOM HART <[email protected]> wrote: >> >>> Is there a way to round currency to the nearest .50, what I want to do >>> is round currency the the nearest dollar or .50 >>> eg >>> >>> $1.76 to $2.00 >>> $1.74 to $1.50 >>> etc >>> >>> Tom Hart >>> >>> >> > -- William Stacy, O.D. Please visit my website by clicking on : http://www.folsomeye.net

