[gdal-dev] GDAL precision for Geometry object
Hermann Peifer
peifer at gmx.eu
Sun Oct 11 09:27:12 PDT 2015
On 2015-10-10 13:45, Dimitrianos Savva wrote:
>
> For example the geometry POINT (4799826.09861662145704
> 2773995.445373429451138) cannot be represented by two double types. But
> still the ExportToWKT function produces the correct result with full
> precision for the values.
While thinking twice about the issue (I might be wrong, though): Isn't
it more of a generic problem that by far most reals (of which there are
infinite many) cannot be *exactly* represented by half, single, double,
quadruple-precision, or by whatever other floating-point format that
could ever be invented in the future? In these cases, the "most accurate
representation" must simply be good enough, as one can't do much about it?
Your sample value above is 4799826.09861662145704 (decimal):
The most accurate representation as double is:
4.79982609861662145704030990601E6 (decimal), 0x41524F54864FBC17 (hex)
and : 01000001 01010010 01001111 01010100 10000110 01001111 10111100
00010111 (binary). That's just how it is, or is there another problem,
of which I wouldn't be aware?
I took the "most accurate" values from
http://www.binaryconvert.com/result_double.html
@Even: I also tried to imagine a reasonable real-life coordinate value
that would generate scientific notation when printed with "%.15g" or:
"%.17g" (as hamish mentioned in this old ticket). Can you point me to one?
Hermann
More information about the gdal-dev
mailing list