
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
Compute modulus division by a power-of-2-number 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
- Related Articles
- Program to find modulus of a number by concatenating n times in Python
- Nearest power 2 of a number - JavaScript
- Python program to compute the power by Index element in List
- Check if given number is a power of d where d is a power of 2 in Python
- Number of pairs whose sum is a power of 2 in C++
- Explain the process of division by 3 digit number.
- How to check if a number is a power of 2 in C#?
- Compute the condition number of a matrix in linear algebra using 2 norm in Python
- Number of digits in 2 raised to power n in C++
- Calculating power of a number in MySQL?
- Solve the following by long division method:3528 divided by 2.
- Compute the condition number of a matrix in linear algebra using negative 2 norm in Python
- C++ Program to compute division upto n decimal places
- Function to compute factorial of a number in JavaScript
- Solve by long division method.$15 a^{3}+3 a^{4}+10 a^{2}+5 a+3$ by $3 a^{2}+1$.

Advertisements