开发者

how to find modulus of a number in c#

how to find modulus of a number in c# .net开发者_运维问答?


With the modulus operator %:

int x = 4545;
int mod = x % 16;


Via the '%' operator.

e.g. int i = 10 % 3; (result: i is 1)


Use this site

http://www.willasrari.com/blog/use-c-modulus-operator-to-determine-even-or-odd-numbers/000166.aspx

Basically the % opearator: x%y

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜