[gdal-dev] Precission problem with atof
mateusz at loskot.net
Wed Jul 22 19:40:54 EDT 2009
Jorge ArĂŠvalo wrote::
> Context: GDAL WKT Raster Driver
> While creating the Dataset, I execute this query:
> SELECT srid, ST_AsText(extent), pixelsize_x, pixelsize_y, blocksize_x,
> blocksize_y FROM raster_columns WHERE r_table_name = 'table' AND
> r_column = 'rast'
> I have loaded a 3-band tiff file with gdal2tiles. Its pixel size is
> 0.9. If I execute this line (over the result of the previous query):
> fPixelSizeX = atof(PQgetvalue(hPGresult, 0, 2));
> I get 0.899999976158142 instead of 0.9.
> The string obtained wiht PQgetvalue is "0.9", but, for any reason,
> atof transform this string in 0.899999976158142.
> So, seems to be a
> precission problem. think the string used by atof has any problem, but
> I'm not sure
Most computers suffer of this problem.
> What should I do?
You need to learn how to live with that problem :-)
> I tried to change atof(nptr) for strtod(nptr,
> (char**)NULL), but it didn't work...
And it won't help.
More information about the gdal-dev