[gdal-dev] GDAL precision for Geometry object

Hermann Peifer peifer at gmx.eu
Fri Oct 16 11:14:44 PDT 2015


On 2015-10-16 18:20, Even Rouault wrote:
> Le vendredi 16 octobre 2015 17:57:10, Hermann Peifer a écrit :
>> On 2015-10-12 11:28, Even Rouault wrote:
>>> I've changed to '%.15g' formatting for WKT in
>>> https://trac.osgeo.org/gdal/ticket/6145
>>
>> Hi Even,
>>
>> Why did you choose '%.15g', rather than '%.17g'? The latter format
>> should guarantee a lossless binary->decimal->binary round-trip, whereas
>> the former one might also do -- or not. I don't think that any precision
>> loss between '%.15g', and '%.17g' would result into "a real life
>> problem", I am asking just out of curiosity.
>
> Hi Hermann,
>
> re'adding the list in CC.
>
> Your point is valid. My idea was to avoid making WKT returned by the modified
> version potentially longer than it is currently
>

I am pretty sure you know: '%.17g' could also result into shorter string 
values, compared to the earlier '%.15f', as in the below (admittedly 
unfair) example.

Hermann

$ printf "%.15f\n" 50.375
50.375000000000000
$
$ printf "%.17g\n" 50.375
50.375



More information about the gdal-dev mailing list