|
of_bitwiseand
|
|
Full name
|
pfc_n_cst_numerical.of_bitwiseand
|
Access
|
public
|
Extend of
|
long
|
Return value
|
long
|
Prototype
|
public function long of_bitwiseand(long,long)
|
Name
|
Datatype
|
lb_Value1
|
Boolean[32]
|
lb_Value2
|
Boolean[32]
|
li_Cnt
|
Integer
|
ll_Result
|
Long
|
public function long of_bitwiseand (long al_value1, long al_value2);//////////////////////////////////////////////////////////////////////////////
//
// Function: of_BitwiseAnd
//
// Access: public
//
// Arguments:
// al_Value1 The first value to be used in the operation. (e.g. 55)
// al_Value2 The second value to be used in the operation. (e.g. 44)
//
// Returns: Long
// The result of the AND operation (e.g. 36)
// If either argument's value is NULL, function returns NULL.
//
// Description: Performs a bitwise AND operation (al_Value1 && al_Value2),
// which ANDs each bit of the values.
// (55 && 44) = 36
//
//////////////////////////////////////////////////////////////////////////////
//
// Revision History
//
// Version
// 5.0 Initial version
//
//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1996-1997 Sybase, Inc. and its subsidiaries. All rights reserved.
// Any distribution of the PowerBuilder Foundation Classes (PFC)
// source code by other than Sybase, Inc. and its subsidiaries is prohibited.
//
//////////////////////////////////////////////////////////////////////////////
Integer li_Cnt
Long ll_Result
Boolean lb_Value1[32], lb_Value2[32]
// Check for nulls
If IsNull(al_Value1) Or IsNull(al_Value2) Then
SetNull(ll_Result)
Return ll_Result
End If
// Get all bits for both values
For li_Cnt = 1 To 32
lb_Value1[li_Cnt] = of_getbit(al_Value1, li_Cnt)
lb_Value2[li_Cnt] = of_getbit(al_Value2, li_Cnt)
Next
// And them together
For li_Cnt = 1 To 32
If lb_Value1[li_Cnt] And lb_Value2[li_Cnt] Then
ll_Result = ll_Result + (2^(li_Cnt - 1))
End If
Next
Return ll_Result
end function