[QGIS-Developer] round function not working

Nyall Dawson nyall.dawson at gmail.com
Sun Sep 2 17:00:10 PDT 2018


On Sun, 2 Sep 2018 at 20:47, Raymond Nijssen <r.nijssen at terglobo.nl> wrote:
>
> Just discovered similar unexpected rounding behavior, but a bit
> different I think:
>
>
> My expression is this one, to show lengths of tracks on my map, in km:
>
> "etappe" || '\n (' ||
> round((length(transform($geometry,'epsg:4326','epsg:31466'))/1000), 1)
> || ' km)'
>
>
> The rounding does actually work fine, but it seems the conversion from
> my rounded value to a string is the problem.
>
> Here some examples (qgis 3.3):
>
> round(0.99, 1) --> 1
> round(1.00, 1) --> 1
> round(1.01, 1) --> 1
> round(1.02, 1) --> 1
> round(1.03, 1) --> 1
> round(1.04, 1) --> 1
> round(1.05, 1) --> 1.1000000000000001
> round(1.06, 1) --> 1.1000000000000001
> round(1.07, 1) --> 1.1000000000000001
> round(1.08, 1) --> 1.1000000000000001
> round(1.09, 1) --> 1.1000000000000001
> round(1.10, 1) --> 1.1000000000000001
> round(1.11, 1) --> 1.1000000000000001
> round(1.12, 1) --> 1.1000000000000001
> round(1.13, 1) --> 1.1000000000000001
> round(1.14, 1) --> 1.1000000000000001

Which Qt version is this with? Looks like bugs which we experienced with 5.6...

Nyall


More information about the QGIS-Developer mailing list