[gdal-dev] Precission problem with atof
jorge.arevalo at gmail.com
Wed Jul 22 19:01:59 EDT 2009
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. Oh, if I execute double f = atof("0.9") f is 0.9000002
(obtained in gdb).
What should I do? I tried to change atof(nptr) for strtod(nptr,
(char**)NULL), but it didn't work...
Thanks in advance
More information about the gdal-dev