Dear Ivan,
it is not strange, c/c++ evaluate expressions this way.
100.0 * "HC01_VC04" / "HC01_VC03" will give you the right result.
First the multiplication is evaluated (left to right rule), the result is
float, then float over integer gives float result.
/ is really two operators, integer division and float division.
If both operands are integer then integer division is used.
Cheers,
Zoltan
On Fri, 22 Aug 2014, Ivan Santiago wrote:
Hello all:
Thanks Ralf.
The columns used are integer. The resulting column is real, lenght=10
precision=1
Writing "HC01_VC04" / "HC01_VC03" * 100.0
Does not work either.
Applying convert function toreal() to one of the columns, produces correct
results. I checked it against LibreOffice Calc.
BTW:
The calculator has a strange behavior though. I need to sort and sort again the
calculated column to 'refresh' the table values.
QGIS 2.4 32bit under WIN7.
---------------------------
Iván Santiago
GIS Specialist
Information Technologies
Office of Management and Budget
787.725.9420 x 2378
Calle Cruz 254
PO Box 9023228
San Juan, PR 00902-3228
http://gis.pr.gov<http://gis.pr.gov/>
From: Ivan Santiago
Sent: Thursday, August 21, 2014 4:04 PM
To: '[email protected]'
Subject: RE: Field calculator QGIS2.4 division error
Hello all:
Does anyone have had problems with field calculations using the division
operator?
I've tried many times to update a new field using both the old field calculator
and the new interface but they just don't work with division.
Simple operations like:
"HC01_VC04" / "HC01_VC03" * 100
Do not work.
The only workaround I found was to put the function abs into the denominator:
"HC01_VC04" / abs("HC01_VC03") * 100
Then it gives the result but this should be avoidable.
I'll send the table used if anyone want to try it.
Qgis version is 2.4 (32bit) under WIN7.
---------------------------
Iván Santiago
GIS Specialist
Information Technologies
Office of Management and Budget
787.725.9420 x 2378
Calle Cruz 254
PO Box 9023228
San Juan, PR 00902-3228
http://gis.pr.gov<http://gis.pr.gov/>
_______________________________________________
Qgis-user mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/qgis-user