Hi
intereseting, didn't know the left to right rule explained by Zoltan:
Siki Zoltan wrote
100.0 * HC01_VC04 / HC01_VC03 will give you the right result.
First the multiplication is evaluated (left to right rule),...
Learning never stops!
ralf
--
View this message in context:
Hey,
There is no left to right here, / is higher order then * so both these are
the same:
exp = QgsExpression('100.0 * 50 / 2')
exp2 = QgsExpression('50 / 2 * 100.0')
exp.evaluate(), exp2.evaluate()
(2500.0, 2500.0)
What you are seeing is the QGIS expression engine doing the multiply part
Hi Nathan,
are you sure?
QgsExpression('100.0 * 50 / 3').evaluate()
1666.6667
QgsExpression('50 / 3 * 100.0').evaluate()
1600.0
Zoltan
On Sat, 23 Aug 2014, Nathan Woodrow wrote:
Hey,
There is no left to right here, / is higher order then * so both these are
the same:
exp =
Yes. You are right. Never mind me.
Nathan
Hi Nathan,
are you sure?
QgsExpression('100.0 * 50 / 3').evaluate()
1666.6667
QgsExpression('50 / 3 * 100.0').evaluate()
1600.0
Zoltan
On Sat, 23 Aug 2014, Nathan Woodrow wrote:
Hey,
There is no left to right here, / is higher order then *
Hi Ivan,
what type of data (integer, real, string) are HC01_VC04 or HC01_VC03 and
what type od data you defined for the new column you want to create?
If the new column is real, try to use 100.0 (with decimal) instead of 100.
ralf
--
View this message in context:
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.
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
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