将Int增加1% [英] Increasing Int by 1%

查看:75
本文介绍了将Int增加1%的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个var作为Int,包含多个计算用作Int数字(不是双数等)。 b $ b和var等于,应该增加该值的1%。

I have a var as an Int that includes multiple calculations to be used as an Int number (not a double, etc.)
and whatever the var equals, should be increased by 1% of that value.

我在代码中达到了以下内容,但我觉得有些不对劲:

I've reached the following in my code, but I feel something wrong:

int IncreaseBy = 0; // the number is only 1 ~ 10%

var result = (int)(/* some numbers */
                          (/*also numbers*/ + IncreaseBy * 0.100);

Console.WriteLine("Result: " + result.ToString());

是的,我知道它可能正在工作,但它可能并不意味着它是正确的,我希望这个没有双打,并且100%正确。

Yes, I know its probably working but it may not mean its correct,
I want this to be with no doubles, and 100% correct.

如果" IncreaseBy"是0?,是
它还会增加吗?因为如果它是0%,我不希望它增加。

and what if the "IncreaseBy" is 0 ?,
will it still increase ? because I don't want it to be increased if it was 0% by any chance.

谢谢事先。

推荐答案

你好, 

Hello, 

我希望这与没有双打,100%正确。

I want this to be with no doubles, and 100% correct.

Ok。 

您的原始值等于"1"并且您的需求准确地增加了"2%"。

< span style ="color:#333333; font-family:'Segoe UI','Lucida Grande',Verdana,Arial,Helvetica,sans-serif;字体大小:14px的; line-height:20.162px">你有几个选择:

- 0

- 1

- 2

0和1之间没有任何内容。  1和2之间也没有任何内容。

And there is nothing between 0 and 1. There also nothing between 1 and 2.




哪个结果100%正确?


这篇关于将Int增加1%的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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