Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in Field Calculator Results, when using the 'division' operator #19400

Closed
qgib opened this issue Aug 15, 2014 · 1 comment
Closed

Error in Field Calculator Results, when using the 'division' operator #19400

qgib opened this issue Aug 15, 2014 · 1 comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! High Priority

Comments

@qgib
Copy link
Contributor

qgib commented Aug 15, 2014

Author Name: Chinedu Ogbodo (Chinedu Ogbodo)
Original Redmine Issue: 11066
Affected QGIS version: 2.4.0


I created an attribute table for a point shapefile.
The attribute table had 3 columns, apart from the ‘id’ column.
Then, I tried to create a 4th column from two of the already existing columns, using field calculator.
The result of the division operator didn’t look good at all.
In the 4th column, it created a wrong result.
The results of dividing one column by the next, was really wrong. But when I tested the ‘addition’, ‘Subtraction’ and ‘Multiplication’ operator , they checked out fine, except ‘division’.
I observed that the results didn’t display correctly the decimal portion of the output.
I had set the precision level to 4.

For example, 3 / 7 gives 0.0000 (which is wrong) instead of 0. 4285714285714
In other words, it appears to throw away the decimal portions, instead of honour the precision level that was entered. And I think it is a fundamental flaw, which should be fixed.

@qgib
Copy link
Contributor Author

qgib commented Aug 17, 2014

Author Name: Matthias Kuhn (@m-kuhn)


Hi Chinedu,

The calculator works with the format, that parts of the expression are. That means, when you are doing an operation based on two integers (whole numbers), the result will be the same format. That also means, that you just have to change one of the two numbers to a decimal number to get more precise results. In your case this means using:

3.0 / 7

or

3 / 7.0


  • resolution was changed from to wontfix
  • status_id was changed from Open to Closed

@qgib qgib added Bug Either a bug report, or a bug fix. Let's hope for the latter! High Priority labels May 25, 2019
@qgib qgib closed this as completed May 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! High Priority
Projects
None yet
Development

No branches or pull requests

1 participant