From: Mike Sassak Date: 2009-06-19T06:12:17+09:00 Subject: Re: floating point accuracy in JRuby --0016368e252bb6965b046ca5dc42 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit When handling currency I'd suggest storing everything in cents with integers and using a Money library like http://money.rubyforge.org/. You won't have any rounding errors then. On Thu, Jun 18, 2009 at 3:44 PM, Steven D. Arnold < stevena@arnold-software.com> wrote: > [ 03:23 PM (5) omega:thoth ~ ] > jirb > irb(main):001:0> 0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1 > => 0.9999999999999999 > [ 03:33 PM (8) omega:thoth ~ ] > irb > >> 0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1 > => 1.0 > > Disappointing that JRuby does not handle floating point numbers (a) in the > the same way as CRuby and (b) not as accurately. Is the cost of > implementing CRuby's behavior prohibitively high on the JVM, is there a fix > planned in the future? How would JRuby users recommend handling currency on > that platform? > > steven > > --0016368e252bb6965b046ca5dc42--