/////////////////////////////////////////////////////////////////////////////
//
// network.cpp : Contains bitwise operations function wrappers.
//
/////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "PBUtils.h"
#include <stdio.h>

// The bitwise-inclusive-OR operator (|) compares each bit of its first 
// operand to the corresponding bit of its second operand. If either bit 
// is 1, the corresponding result bit is set to 1. Otherwise, the 
// corresponding result bit is set to 0.
// ---------------------------------------------------------------------
PBUTILS_API DWORD __stdcall BitwiseOR( DWORD numA, DWORD numB )
{
	return ( numA | numB );
}

// The bitwise-exclusive-OR operator (^) compares each bit of its first 
// operand to the corresponding bit of its second operand. If one bit 
// is 0 and the other bit is 1, the corresponding result bit is set to 1. 
// Otherwise, the corresponding result bit is set to 0.
// ----------------------------------------------------------------------
PBUTILS_API DWORD __stdcall BitwiseXOR( DWORD numA, DWORD numB )
{
	return ( numA ^ numB );
}

// The bitwise-AND operator (&) compares each bit of its first operand to
// the corresponding bit of its second operand. If both bits are 1, the 
// corresponding result bit is set to 1. Otherwise, the corresponding 
// result bit is set to 0.
// ----------------------------------------------------------------------
PBUTILS_API DWORD __stdcall BitwiseAND( DWORD numA, DWORD numB )
{
	return ( numA & numB );
}

// The one's complement operator, sometimes called the "bitwise complement"
// or "bitwise NOT" operator, produces the bitwise one's complement of its 
// operand. The operand must be of integral type. This operator performs 
// usual arithmetic conversions; the result has the type of the operand 
// after conversion. 
// ------------------------------------------------------------------------
PBUTILS_API DWORD __stdcall BitwiseNOT( DWORD num )
{
	return ( ~num );
}

// The bitwise shift operators shift their first operand left (<<) or 
// right (>>) by the number of positions the second operand specifies. 
// -------------------------------------------------------------------
PBUTILS_API DWORD __stdcall BitwiseLeftShift( DWORD num, USHORT nPositions )
{
	return ( num << nPositions );
}

PBUTILS_API DWORD __stdcall BitwiseRightShift( DWORD num, USHORT nPositions )
{
	return ( num >> nPositions );
}
