开发者

how to find modulus of a number in c#

开发者 https://www.devze.com 2022-12-18 22:19 出处:网络
how to find modulus of a number in c# .net开发者_运维问答?With the modulus operator %: int x = 4545;

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

精彩评论

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