From: Hunter's Lists Date: 2005-12-13T09:21:17+09:00 Subject: Re: Using Float For Currency Thanks. Fortunately this is just some quick guestimation throw-away stuff. No real need for precision. I will take a look at BigDecimal but in the meantime, any thoughts on the original question? Thx > From: > Reply-To: > Date: Tue, 13 Dec 2005 09:12:56 +0900 > To: ruby-talk ML > Subject: Re: Using Float For Currency > > Quoting Hunter's Lists : > >> Howdy, >> >> I have some methods that manipulate floats that represent a >> currency amount. >> >> I often end up with more precision than I need, i.e.: $9.756. >> >> What is the best way to scale that to 9.76? > > If you're doing anything that matters, don't use floats for > currency. There are a lot of really nasty subtle issues that will > lose money between the cracks. > > Usually you want a specialized currency type which uses > fixed-precision arithmetic. > > -mental >