Bug report #11487

Dividing integer with integer gives wrong result (if operation is supposed to return a decimal)

Added by Fabien Cerbelaud over 9 years ago. Updated over 9 years ago.

Status:Closed
Priority:Severe/Regression
Assignee:-
Category:Expressions
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:duplicate
Crashes QGIS or corrupts data:No Copied to github as #:19757

Description

Hi,
When I try to calcul a proportion based on two int field in a float column I obtain nothing. I should obtain something like 82,3 or -12,4 in result.
If I only make one operation it working, for example one int field divide by 2.888 I obtain the good result, but If I make divide operation between two int field the result is 0.000.

bug_1st_screenshot.jpg (1.18 MB) Fabien Cerbelaud, 2014-10-24 03:15 AM

bug_request_screenshot.jpg (1.01 MB) Fabien Cerbelaud, 2014-10-24 03:15 AM


Related issues

Duplicates QGIS Application - Bug report #5153: Unexpected rounding in field calculator (documentation ne... Closed 2012-03-10

History

#1 Updated by Giovanni Manghi over 9 years ago

  • Subject changed from Error in result of operation of field calculator from int to float field to Dividing integer with integer gives wrong result (if operation is supposed to return a decimal)
  • Status changed from Open to Feedback
  • Category changed from Attribute table to Expressions
  • Affected QGIS version changed from 2.4.0 to master
  • OS version deleted (7)
  • Operating System deleted (windows)
  • Priority changed from Normal to Severe/Regression

To replicate it is not necessary to use existing attributes:

10/3 gives 3 (!!!)

10/3.0 gives 3.333333

10.0/3 gives 3.333333

toreal(10)/3 gives 3.333333

is this really the intended behavior?

#2 Updated by Jürgen Fischer over 9 years ago

  • Status changed from Feedback to Closed
  • Resolution set to duplicate

duplicate of #5153

Also available in: Atom PDF