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 Right Shift

using System;
 
namespace Operator
{
	class LeftShift
	{
		public static void Main(string[] args)
		{
			int number = 42;

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

Bitwise Left Shift C#

using System;
 
namespace Operator
{
	class LeftShift
	{
		public static void Main(string[] args)
		{
			int number = 42;

			Console.WriteLine("{0}<<1 = {1}", number, number<<1);
			Console.WriteLine("{0}<<2 = {1}", number, number<<2);
			Console.WriteLine("{0}<<4 = {1}", number, number<<4);
		}
	}
}
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 :: what does - in f#? 
Csharp :: keyboard hook c# 
Csharp :: MailChimp C# Api calls 
Csharp :: unity ik not working 
Csharp :: hva er bukser på amerikansk 
Csharp :: how to mirror an image in vs forms 
Csharp :: block nulltarge tpl dataflow 
Csharp :: forces the user to enter his password before submitting the form asp.net core 
Csharp :: enemy turret one direction ahooting script unity 2d 
Html :: favicon meta 
Html :: html input integer and positive 
Html :: default html template 
Html :: create a mailto link html 
Html :: html input regex only numbers 
Html :: bootstrap Bootstrap link 
Html :: button verlinken html 
Html :: html disable enter submit 
Html :: html dot symbol 
Html :: html disable first option 
Html :: Add a viewport meta tag to the document head to set the width of the layout viewport equal to the width of the device and set the initial scale of the viewport to 1.0. 
Html :: facebook share link html 
Html :: bootstrap flex align 
Html :: font awesome cdn 
Html :: fafa login icons html code 
Html :: set icon for html page tab 
Html :: minimal acceptable html 
Html :: align image center of webpage 
Html :: include favicon html 
Html :: remove click efect bootstrap 
Html :: how to center the mainin html 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =