datamapper / do

DataObjects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

postgres - precision lost when casting on double precision

donhill opened this issue · comments

I have a table that is using a type of double precision. I am trying to perform a round(cast(column as numeric),2). When I perform this in psql I get the correct results. So 17.1799913573964 becomes 17.18. When I am using the datamapper postgre driver I get the value 0.1718E2. Any thoughts on this. Here is the psql query.

select id, round(cast(distance as numeric),2) miles, distance from (SELECT id, ( 3959 * acos( cos( radians(42.0926245) ) *cos( radians( lat ) ) * cos( radians( lng ) - radians(-88.1152973) ) + sin( radians(42.0926245) ) * sin(radians( lat ) ) ) ) AS distance FROM operator_positions ) position where distance < 20

I don't really understand the issue. 0.1718E2 seems to be the same as 17.18 to me.

Me too:

2.0.0p247 :001 > 0.1718E2 == 17.18
 => true