如何在C#中计算整数的除法和取模? [英] How can I calculate divide and modulo for integers in C#?
本文介绍了如何在C#中计算整数的除法和取模?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在C#中计算整数的除法和取模?
How can I calculate division and modulo for integer numbers in C#?
推荐答案
Before asking questions of this kind, please check MSDN documentation.
当您将两个整数相除时,结果始终是整数.例如,结果7/3为2.要确定7/3的余数,请使用余数运算符(
int a = 5; int b = 3; int div = a / b; //quotient is 1 int mod = a % b; //remainder is 2
这篇关于如何在C#中计算整数的除法和取模?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文