2010-01-01 51 views
0

differencePercentage = Math.round(((Pay.init/Pay.current)* 100) - 100);百分比值的极化移位

并且这给了我在初始和当前薪酬之间的百分比差异,但它是相反的。当它是正值时,即薪酬高于初始值时表示-X%,当它低于时表示X%。

有没有什么明显的方法,我没有看到这极化?

感谢您的任何见解。 :)

回答

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

[ - (一 - B)= -a + B = - A]

另外:

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

非常感谢你们双方。我会起床代表我所以我可以++你嘿。 – aethys 2010-01-01 05:52:13

-1

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