I have
local x%, y%, z
x%=-10
y%=20
z=y%/x%
print z
Gives -2
But if I write z=x%/y%
It gives 0 instead of -1/2
Why???
I have
local x%, y%, z
x%=-10
y%=20
z=y%/x%
print z
Gives -2
But if I write z=x%/y%
It gives 0 instead of -1/2
Why???
Ok, I solved my problem what this caused...
But still confused why is it so..?
if you divide integers, you'll end up with an integer result. If you want to have a real result convert the ints to reals before division (curiously you can use the int function for this):
z = int(x%)/int(y%)