如何计算十进制v1 =(test.rpmrequired),十进制v2 = test.rpmrequired * 14/100和十进制v3 = v1-v2? [英] How to calculate decimal v1 = (test.rpmrequired) , decimal v2 = test.rpmrequired * 14/100 and decimal v3 = v1-v2?

查看:86
本文介绍了如何计算十进制v1 =(test.rpmrequired),十进制v2 = test.rpmrequired * 14/100和十进制v3 = v1-v2?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

decimal v1 = (test.rpmRequired);
           decimal v2 = test.rpmRequired * 14/100;
           decimal v3 = v1-v2;





我尝试过:





What I have tried:

decimal v1 = (test.rpmRequired);
           decimal v2 = test.rpmRequired * 14/100;
           decimal v3 = v1-v2;

推荐答案

可能,它很简单:停止使用整数!

当你除以整数值时,你得到一个整数结果 - 然后被转换为十进制值乘以RPM。由于14小于100,14 / 100为整数0,因此整个计算结果总是为零。

尝试为所有常量添加M后缀以强制它们是小数值。



如果不能解决问题,你需要告诉我们你的期望和你得到的东西。
Probably, it's simple: stop using integers!
When you divide you integer values, you get an integer result - that then gets cast to a decimal value to multiply by the RPM. Since 14 is less than 100, 14/100 is 0 as an integer, so you always get zero as a result of the whole calculation.
Try adding an M suffix to all your constants to force them to be decimal values.

If that doesn't fix it, you need to tell us exactly what you expect, and what you are getting.


这篇关于如何计算十进制v1 =(test.rpmrequired),十进制v2 = test.rpmrequired * 14/100和十进制v3 = v1-v2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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