Bug report #6640
Problem with round function of the expression builder
|Affected QGIS version:||master||Regression?:||No|
|Operating System:||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||15820|
I found a strange behavior with round function of the expression builder.
When the round is done to integer, everything seems going well. However, by introducing one or more decimal places, the results begin to be strange and often appears the default value -21474836.48.
Here ( ,  , ) is an example with rounding areas in labels. The problem happens starting from 2 decimal places. Doing the same with the perimeter, the problem happens starting from 5 decimal places.
The data I am using are the portuguese administrative boundaries , but I tested it with other data and also happens.
Gioseppe Sucameli has also confirmed this problem:
-2147483648 is the min integer value, so probably the way to round number fails somewhere. I can see that each trailing '0' is removed, in addition incrementing the number of decimal places the value becomes negative: "PM" || ' ' || round( "PM", 6 ) || ' ' || round( "PM", 12 ) outputs 218317.69947 -2147.483648 -0.002147483648
I'm using QGIS master (ubuntugis unstable) on Xubuntu 12.04 and Gioseppe is using Ubuntu 11.04.
#1 Updated by Giovanni Manghi over 7 years ago
- Target version set to Version 2.0.0
- Category deleted (
- Status changed from Open to Feedback
- Assignee set to Nathan Woodrow
I agree with Giuseppe, that |number| is the min/max value for integers in a shapfile, so it must be something wrong with rounding.
Is this a regression? can anyone check with an older release?
Please note that there is another ticket asking to add a warning anytime for some reason the length limit of shapes fields is passed, in order to avoid have users guess why their columns are filled with strange values. If possible add your note there also.
I'm giving this ticket to Nathan because he worked lately in the expression builder, but I don't know if he is the right person anyway. Nathan in case just remove your name.
#5 Updated by Anita Graser almost 7 years ago
- Priority changed from Normal to High
I think this bug is much more important. Testing Select by expression, I ran into the following odd situation: I'm
using the lakes.shp from the QGIS sample data and the following two expressions return different results:
$area > 28386358480
selects all lakes, even though only one is that big
$area > 28386358480.0
returns the correct result and only one lake is selected.
This should really be fixed for 2.0.