[QGIS-Developer] round function not working

Raymond Nijssen r.nijssen at terglobo.nl
Sun Sep 2 23:19:39 PDT 2018


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.

Raymond



More information about the QGIS-Developer mailing list