
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Compute Modulus Division by a Power of 2 in C#
We have taken the number as the following −
uint a = 9; uint b = 8;
Above, a is a divisor and b is dividend.
To compute modulus division.
Example
using System; class Demo { static uint display( uint a, uint b) { return ( a & (b-1) ); } static public void Main () { uint a = 9; uint b = 6; Console.WriteLine( a + " modulus " + b + " = " + display(a, b)); } }
Output
9 modulus 6 = 1
Advertisements