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 :: control shot c# WF 
Csharp :: get 24 hour time in c# 
Csharp :: how to controller request in c# 
Csharp :: process method in scala 
Csharp :: Click an HTML link inside a WebBrowser Control 
Csharp :: add auto mapper in startup 
Csharp :: how to show enum name list from input in swagger c# 
Csharp :: ActionExecutingContext result response return objects 
Csharp :: detect location from ip address .net core 
Csharp :: how to add onclick event dynamically in unity 
Csharp :: unity player movement script 3d 
Csharp :: how to detect a null bool C# 
Csharp :: clickable table row asp.net core cursor 
Csharp :: where are the viwes in .net core publish 
Csharp :: C# string array in setter 
Csharp :: how to check that a gameobject touches a colour in unity c# 
Csharp :: c# Difference Array | Range update query in O(1) 
Csharp :: tmpro pageCount update 
Csharp :: world space constant size 
Csharp :: unity check if swipe not tap 
Csharp :: c# get first and last day of current month 
Csharp :: Console.WriteLine($"Hello {Ana.ToUpper($)}!"); 
Csharp :: asp.net mvc select from many to many relationship 
Csharp :: string in char list f# 
Csharp :: 403 forbidden error using Windows Forms 
Csharp :: catwherehouse 
Csharp :: C# Move Camera Over Terrain Using Touch Input In Unity 3D - Append To Camera 
Csharp :: IOS app crashing on ios 15 unity 
Csharp :: C# WriteLine() and Write() 
Csharp :: log4net rollingfileappender c# 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =