[QGIS-Developer] round function not working

Nyall Dawson nyall.dawson at gmail.com
Sun Sep 2 23:39:57 PDT 2018


On Mon, 3 Sep 2018 at 16:19, Raymond Nijssen <r.nijssen at terglobo.nl> wrote:
>
> On 03-09-18 02:00, Nyall Dawson wrote:
> > 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
> >
>
> Yes, 5.5.1
>
> Will it be solved with a newer version? I'm going to test it this week.

Yes - Qt fixed this bug in 5.7.

It caused us endless headaches during the 3.0 development cycle, but
in the end we couldn't solve it and the only fix is upgrading Qt. I'd
suggest you really want at least 5.9 now.

Nyall


More information about the QGIS-Developer mailing list