<p dir="ltr">Yes. You are right. Never mind me.</p>
<p dir="ltr">Nathan </p>
<div class="gmail_quot<blockquote class=" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Nathan,<br>
<br>
are you sure?<br>
QgsExpression('100.0 * 50 / 3').evaluate()<br>
1666.666666666667<br>
<br>
QgsExpression('50 / 3 * 100.0').evaluate()<br>
1600.0<br>
<br>
Zoltan<br>
<br>
On Sat, 23 Aug 2014, Nathan Woodrow wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hey,<br>
<br>
There is no left to right here, / is higher order then * so both these are<br>
the same:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
exp = QgsExpression('100.0 * 50 / 2')<br>
exp2 = QgsExpression('50 / 2 * 100.0')<br>
exp.evaluate(), exp2.evaluate()<br>
</blockquote></blockquote>
(2500.0, 2500.0)<br>
<br>
What you are seeing is the QGIS expression engine doing the multiply part<br>
result first, which returns a float, then it will say "is the left side a<br>
int AND the right side a int" if that comes back as NO then it does a float<br>
operation.  Basically this means once one of the values in the equation is<br>
a float the result will come out as float.<br>
<br>
If you want to see the details on how this works you can find it here<br>
<a href="https://github.com/qgis/QGIS/blob/master/src/core/qgsexpression.cpp#L2093" target="_blank">https://github.com/qgis/QGIS/<u></u>blob/master/src/core/<u></u>qgsexpression.cpp#L2093</a><br>
<br>
- Nathan<br>
<br>
<br>
On Sat, Aug 23, 2014 at 8:22 PM, ralfwessels <<a href="mailto:gis@ralf-wessels.de" target="_blank">gis@ralf-wessels.de</a>> wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi<br>
intereseting, didn't know the left to right rule explained by Zoltan:<br>
<br>
Siki Zoltan wrote<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
100.0 * "HC01_VC04"  /  "HC01_VC03" will give you the right result.<br>
First the multiplication is evaluated (left to right rule),...<br>
</blockquote>
<br>
Learning never stops!<br>
ralf<br>
<br>
<br>
<br>
--<br>
View this message in context:<br>
<a href="http://osgeo-org.1560.x6.nabble.com/Re-Field-calculator-QGIS2-4-division-error-tp5157715p5157980.html" target="_blank">http://osgeo-org.1560.x6.<u></u>nabble.com/Re-Field-<u></u>calculator-QGIS2-4-division-<u></u>error-tp5157715p5157980.html</a><br>

Sent from the Quantum GIS - User mailing list archive at Nabble.com.<br>
______________________________<u></u>_________________<br>
Qgis-user mailing list<br>
<a href="mailto:Qgis-user@lists.osgeo.org" target="_blank">Qgis-user@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-user" target="_blank">http://lists.osgeo.org/<u></u>mailman/listinfo/qgis-user</a><br>
<br>
</blockquote>
<br>
</blockquote>
</div>