Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

C# bitwise operation

ulong x = 73473458374534587UL;
//0 0 0 0 0 0 0 1
//0 0 0 0 0 1 0 1
//0 0 0 0 0 1 1 1
//1 0 1 1 1 0 0 0
//1 0 0 1 1 0 1 0
//1 1 0 1 0 1 0 1
//0 1 1 0 0 1 0 1
//1 0 1 1 1 0 1 1

ulong y = 635528292UL;
//0 0 0 0 0 0 0 0
//0 0 0 0 0 0 0 0
//0 0 0 0 0 0 0 0
//0 0 0 0 0 0 0 0
//0 0 1 0 0 1 0 1
//1 1 1 0 0 0 0 1
//0 1 1 0 0 1 0 0
//0 1 1 0 0 1 0 0

//x|y will get all ths bits set in x or y or both
//x^y will get all the bits set in x or y, but not both
//x&y will get all the bits set in x and y

var bitor = x|y; //73473458997388799
//0 0 0 0 0 0 0 1
//0 0 0 0 0 1 0 1
//0 0 0 0 0 1 1 1
//1 0 1 1 1 0 0 0
//1 0 1 1 1 1 1 1
//1 1 1 1 0 1 0 1
//0 1 1 0 0 1 0 1
//1 1 1 1 1 1 1 1

var exor = x^y; //73473458984714719
//0 0 0 0 0 0 0 1
//0 0 0 0 0 1 0 1
//0 0 0 0 0 1 1 1
//1 0 1 1 1 0 0 0
//1 0 1 1 1 1 1 1
//0 0 1 1 0 1 0 0
//0 0 0 0 0 0 0 1
//1 1 0 1 1 1 1 1

var bitand = x&y; //12674080
//0 0 0 0 0 0 0 0
//0 0 0 0 0 0 0 0
//0 0 0 0 0 0 0 0
//0 0 0 0 0 0 0 0
//0 0 0 0 0 0 0 0
//1 1 0 0 0 0 0 1
//0 1 1 0 0 1 0 0
//0 0 1 0 0 0 0 0
Comment

C# bitwise operation


var cnt = 1
var l = 1
if ((cnt & l)==0){ // false }

00000001
00000001
===============
00000001

Comment

C# Bitwise OR

using System;
 
namespace Operator
{
	class BitWiseOR
	{
		public static void Main(string[] args)
		{
			int firstNumber = 14, secondNumber = 11, result;
			result = firstNumber | secondNumber;
			Console.WriteLine("{0} | {1} = {2}", firstNumber, secondNumber, result);
		}
	}
}
Comment

C# Bitwise AND

using System;
 
namespace Operator
{
	class BitWiseAND
	{
		public static void Main(string[] args)
		{
			int firstNumber = 14, secondNumber = 11, result;
			result = firstNumber & secondNumber;
			Console.WriteLine("{0} & {1} = {2}", firstNumber, secondNumber, result);
		}
	}
}
Comment

bitwise and c#

& //bitwise AND for c#
Comment

C# Bitwise and Bit Shift Operator

using System;
 
namespace Operator
{
	class BitOperator
	{
		public static void Main(string[] args)
		{
			int firstNumber = 10;
			int secondNumber = 20;
			int result;

			result = ~firstNumber;
			Console.WriteLine("~{0} = {1}", firstNumber, result);

			result = firstNumber & secondNumber;
			Console.WriteLine("{0} & {1} = {2}", firstNumber,secondNumber, result);

			result = firstNumber | secondNumber;
			Console.WriteLine("{0} | {1} = {2}", firstNumber,secondNumber, result);

			result = firstNumber ^ secondNumber;
			Console.WriteLine("{0} ^ {1} = {2}", firstNumber,secondNumber, result);

			result = firstNumber << 2;
			Console.WriteLine("{0} << 2 = {1}", firstNumber, result);

			result = firstNumber >> 2;
			Console.WriteLine("{0} >> 2 = {1}", firstNumber, result);
		}
	}
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# allowedusernamecharacters 
Csharp :: bsod screen c# 
Csharp :: c# string to bool 
Csharp :: get all classes that extend a class c# 
Csharp :: how to get the size an array in unity 
Csharp :: string tochararray c# 
Csharp :: all Substring of String 
Csharp :: c# next level script 
Csharp :: wpf clear grid 
Csharp :: c# remove the last character of a string 
Csharp :: yield c# 
Csharp :: .net 6 autofac 
Csharp :: how to find player gameobject in unity 
Csharp :: Raycasting to find mouseclick on Object in unity 2d games 
Csharp :: pause unity game 
Csharp :: how to use curl in asp.net c# 
Csharp :: vb.net get date minus one day 
Csharp :: c# dictionary get key by value 
Csharp :: Unity rainbow color changing object 
Csharp :: unity agent look at 
Csharp :: longest substring without repeating characters leetcode 
Csharp :: expando object c# 
Csharp :: C# program lambda Func 
Csharp :: remove duplicates in the list using linq 
Csharp :: how to populate list in c# 
Csharp :: csharp Console.Read(); 
Csharp :: C# The request was aborted: Could not create SSL/TLS secure 
Csharp :: How do I allow edit only a particular column in datagridview in windows application 
Csharp :: unity draw waypoins path 
Csharp :: c# external ip 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =