开发者

Polarized shift of percentage values

differencePercentage = Math.round(((Pay.init / Pay.curr开发者_如何学Cent) * 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. :)


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)));


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜