From: Clifford Heath Date: 2009-02-13T15:23:36+09:00 Subject: Re: Bug in converting float to int? Jeff Vogt wrote: > I just tried this on 1.8.6. Is this a bug or am I missing something? Wikipedia is good, but I think the best-known article on this is here: , entitled "What Every Scientist Should Know About Floating-Point Arithmetic". > And if this is in fact intended behavior, how can I actually get the > results I want? (Converting dollars and cents into cents) Avoid using floating point. Seriously. Some might advice you to round: (a*100).round => 1012, but that's *unreliable*, even with some quite small number of digits. Store cents as an integer, or use BigDecimal. Clifford Heath.