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 :: unity reload script assemblies 
Csharp :: extension of c sharp 
Csharp :: c# datagridview filter 
Csharp :: minimum value int C# 
Csharp :: unity c# request store review 
Csharp :: Create an array with random values c# 
Csharp :: unity new input system get button down 
Csharp :: c# use enum in class 
Csharp :: c# second last index 
Csharp :: millie bobby brown age 
Csharp :: unity public script 
Csharp :: how to make the player look around in unity 3d 
Csharp :: wie macht man eine schleife in c# 
Csharp :: c# reduce a collection to a string 
Csharp :: enemy turret one direction ahooting script unity 2d 
Html :: html yen symbol 
Html :: favicon html 
Html :: regex href html pattern 
Html :: tag for tel 
Html :: bootstrap 5 overflow 
Html :: notyf 
Html :: html select required 
Html :: tailwind cdn 
Html :: laravel blade remove all html tags 
Html :: confuse your browser in html 
Html :: meta icon html 
Html :: meta theme color 
Html :: make a basic html page 
Html :: bootstrap 4 stop auto slide 
Html :: ordered list with roman numerals html 
ADD CONTENT
Topic
Content
Source link
Name
4+4 =