stefan1919

Create mask with size n

Aug 28th, 2015
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.49 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication4
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int maskSize = 4 + 1;
  14.             int mask = 1 << maskSize;
  15.             mask -= 1;// when we receive mask - 1 and mask was 10000 the result is 1111 that is why we have to add +1 in the beggining
  16.             Console.WriteLine(mask);
  17.         }
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment