Log in

View Full Version : Math bug, perhaps.


dvd2svcd
12th August 2003, 15:33
If I do this:

i=(150000 / 100 * 4)
MessageClip(String(i))

The result is 375 (Wrong should be 6000)


If I do this:

i=(150000 / 100) * 4
MessageClip(String(i))

The result is 6000 (Right)


If I do this:

i=150000 / (100 * 4)
MessageClip(String(i))

The result is 375 (Right)

If I do the first calculation in my calculator I get 6000. If I do it in Delphi I get 6000. And as far as I remember, * and / has the same priority and should always be calculated from left to right if no parenthesis is used.

arlsair
12th August 2003, 17:23
AviSynth docu (http://www.avisynth.org/index.php?page=logical+operators)
AviSynth parses expressions from right to left, which can give unexpected results.

Bidoche
12th August 2003, 17:24
Oups, seems we overlooked the multiplication/division case when we corrected this for addition/substraction.

It's a bug of course. Thanks for pointing it out.

stickboy
12th August 2003, 17:32
Originally posted by arlsair
AviSynth docu
AviSynth parses expressions from right to left, which can give unexpected results.It's not supposed to be that way anymore (http://forum.doom9.org/showthread.php?s=&postid=338924#post338924).

arlsair
12th August 2003, 17:47
Ok, sorry. I have to read more.

Wilbert
12th August 2003, 19:11
It's not your fault. It's not well documented yet :)

WarpEnterprises
12th August 2003, 21:43
@bidoche: is it hard to repair? Would be nice before 2.53.

Bidoche
12th August 2003, 22:22
Well, I fear it will be kinda complicated.
It was more a hack than a real fix for +/-, avisynth still makes the operation for right to left but this way :
10 - 5 - 5 is associated 10 + (-5 - 5)
which make it find the good answer.

But 10 / 2 * 5 associated 10 * (1/2 * 5) does not work out if we are working with ints.

Bidoche
13th August 2003, 11:57
Just committed a fix so multiplications are done from left to right (in scriptparser.cpp rev 1.6)