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

PREVIOUS NEXT
Code Example
Csharp :: c# quaternion eular calculator 
Csharp :: how to textbox anywhere on chart in c# 
Csharp :: how to call method in different project in c# visual studio 
Csharp :: unity using tmpro not working 
Csharp :: Acrylic UWP Title bar C# 
Csharp :: dotnet DB context register 
Csharp :: c# operators 
Csharp :: convert string to boolean c# 
Csharp :: how to get image from resource folder in c# 
Csharp :: how to create a point c# 
Csharp :: how to not overwrite a text file in c# 
Csharp :: c# position of character in string 
Csharp :: swagger skip endpoint .net core 
Csharp :: deserialize list of objects c# 
Csharp :: make sprite invisible unity 
Csharp :: unity audio source playoneshot 
Csharp :: unity add text to text field without deleting the old one 
Csharp :: embed video to exe file with c# 
Csharp :: polling data source c# using threads 
Html :: html 5 default code 
Html :: text-bold bootstrap 
Html :: html input regex only numbers 
Html :: html disable drag image 
Html :: tab space in html 
Html :: center p html 
Html :: html iframe full page 
Html :: make div clickable 
Html :: youtube video image 
Html :: embed string html angular 
Html :: howto include the single quotes in html 
ADD CONTENT
Topic
Content
Source link
Name
9+2 =