如何计算百分比 [英] How to calculate a percentage

查看:301
本文介绍了如何计算百分比的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想计算一个百分比。我的代码是:

I want to calculate a percentage. My code is:

Bot.Log("[ KEYBOT ] The total is " + (suctrades * totaltrades ) / 100 + "% !");

如果这样做,我只会得到0。我在做什么错了?

If I do this, I only get 0. What am I doing wrong?

推荐答案

可能 suctrades * totaltrades 仍然是 int 。最简单的方法可能是将代码更改为:

Probably suctrades * totaltrades is still an int. The easiest way will be probably changing your code to:

((double)suctrades) * totaltrades/100

suctrades * totaltrades/100.0

强制使用 double 而不是 int

这篇关于如何计算百分比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆