From: Phillip Gawlowski Date: 2010-01-15T14:32:27+09:00 Subject: Re: Float Points error On 15.01.2010 05:56, THAKUR PRASHANT SINGH wrote: > While retrieving from array I get some number like 22.09000015. > > So when I do groupings I miss out my original number as 22.09< > 22.09000015 > > Where as it should come in a group where numbers are 22.09>= 22.09 Floats aren't exact, they are approximations: IEEE 754-2008 > I wish to have last condition returning true.Is there any simple way to > do that as my dataset contains around a million numbers. Short of implementing a #rounding method (1.8.6 Core does only integer rounding, after a curious check; STDLIB, 1.8.7 and 1.9.1 might have a different behavior) to the accuracy you need: No. Or you could implement a custom comparison operator that does what you need. > If I use conversion to string and back to to_f I lose time of > approximately 10 secs for each 7000 rows. You'll loose time when computing with Floats, anyway, since outside of vector-based CPUs (IIRC), the performance of performing maths on floats is terrible (in relative terms). -- Phillip Gawlowski