Hi Nathan,
are you sure?
QgsExpression('100.0 * 50 / 3').evaluate()
1666.666666666667
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 = 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
result first, which returns a float, then it will say "is the left side a
int AND the right side a int" if that comes back as NO then it does a float
operation. Basically this means once one of the values in the equation is
a float the result will come out as float.
If you want to see the details on how this works you can find it here
https://github.com/qgis/QGIS/blob/master/src/core/qgsexpression.cpp#L2093
- Nathan
On Sat, Aug 23, 2014 at 8:22 PM, ralfwessels <[email protected]> wrote:
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:
http://osgeo-org.1560.x6.nabble.com/Re-Field-calculator-QGIS2-4-division-error-tp5157715p5157980.html
Sent from the Quantum GIS - User mailing list archive at Nabble.com.
_______________________________________________
Qgis-user mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/qgis-user
_______________________________________________
Qgis-user mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/qgis-user