Bug report #11182

Expression editor in Layer Properties does not support division of integer data

Added by d d about 5 years ago. Updated about 5 years ago.

Status:Closed
Priority:High
Assignee:-
Category:Expressions
Affected QGIS version:2.4.0 Regression?:No
Operating System:Linux Easy fix?:No
Pull Request or Patch supplied:No Resolution:worksforme
Crashes QGIS or corrupts data:No Copied to github as #:19495

Description

Affected function: under Layer Properties --> Style --> Graduated --> Expression

Issue: writing an expression that divides values in two separate columns (type: int; length: 10) of an ESRI SHP file results in incorrect value (0). Addition, subtraction, and multiplication all work as expected and produce sensible results.

Expected behaviour: when dividing two integer values, the result should be promoted to a real value.

The Expression editor is non-functional in its present state.


Related issues

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

History

#1 Updated by d d about 5 years ago

  • Target version changed from Future Release - High Priority to Version 2.6

#2 Updated by d d about 5 years ago

It looks like this was discussed previously, but never resolved: #5153

#3 Updated by Jürgen Fischer about 5 years ago

  • Resolution set to worksforme
  • Status changed from Open to Closed

d d wrote:

It looks like this was discussed previously, but never resolved: #5153

That's the intended behaviour. Division of integers produce integers. You can convert either argument using to real(int) to produce a floating point result.

Also available in: Atom PDF