This simple postgres round call rounds the numeric to 3 decimal places, as expected:
SELECT round(43.1235421,3);
round
--------
43.124
(1 row)
However, the exact same round operation in the query below gives me 43.1240000000000023. The query is run against a postgis database, in case that makes a difference.
(SELECT ogc_fid,wkb_geometry,round(43.1235421,3) AS lat FROM grid_1) AS "grid"
This behaviour is undesired. What am I doing wrong? How can I get a float rounded to 3 decimal places, as expected? Thanks in advance.
EDIT: I tried explicitly casting the float as a numeric in the postgis query, but got the same result.
(SELECT ogc_fid,wkb_geometry,round(43.1235421::numeric,3) AS lat FROM grid_1) AS "grid"