Page 1 of 1
maths
Posted: Thu Apr 11, 2013 3:51 pm
by enric
Which is the correct syntax for removing a 30% of a value:
damage *= 0,7; // don't work (the 0.7 is not accepted by BA)
damage = damage * 7 / 10 ; // don't work
damage = damage * 7;
damage = damage / 10; Then it works but should be a better way no?
Re: maths
Posted: Thu Apr 11, 2013 4:02 pm
by pipfromslitherine
The script doesn't deal with precedence in the same way as regular C. The second approach is the recommended solution.
Cheers
Pip
Re: maths
Posted: Fri Apr 12, 2013 6:07 am
by Amaris
Why so complicated?
I think it works:
damage = damage % 70;

Re: maths
Posted: Fri Apr 12, 2013 2:17 pm
by enric
Thank Amaris, this works in the way that BA accept it but, unfortunately the result is not the searched.
damage = damage * 7;
damage = damage / 10; Then it works but should be a better way no?
If damage value was initially 100, after calculations is 70.
in your example
damage = damage % 70;
gives as result 30.
if using:
damage = damage % 30;
the result is 10 ????
Re: maths
Posted: Fri Apr 12, 2013 2:33 pm
by Amaris
Sorry I'm mistaken!

I didn't have BA under hand when I wrote this stupidity thing.
The % operator is the remainder of the Euclidean division.
Therefore the solution:
damage = damage * 7;
damage = damage / 10;
is better...
edit: correction of a second very stupid thing...