views:

24

answers:

2

Hi I have this in AS3

differencePercentage = Math.round(((Pay.init / Pay.current) * 100) - 100);

and that gives me the difference in percent between initial and current pay, but it's reversed. When it's positive i.e. pay is above the initial value it says -X%, and when it's below it says X%.

Is there any obvious way I'm not seeing to polarize this?

Thanks for any insight. :)

+1  A: 
differencePercentage = Math.round(100 - ((Pay.init / Pay.current) * 100));

[-(a - b) = -a + b = b - a]

Also:

differencePercentage = Math.round(100 * (1 - (Pay.init / Pay.current)));
Tordek
Great amazing thanks to both of you..I'll get up my rep so I can ++ you hehe.
aethys
A: 

differencePercentage = Math.round(((Pay.current / Pay.init) * 100) - 100);

NineBerry