function bitxor(long value1,value2) return long value
//32位异或运算
For ll_Bit = 0 To 31
If ( ( Mod( Long( Value1 / 2^ll_Bit ), 2 ) = 1 And &
Mod( Long( Value2 / 2^ll_Bit ), 2 ) = 0 ) ) Or &
( ( Mod( Long( Value1 / 2^ll_Bit ), 2 ) = 0 And &
Mod( Long( Value2 / 2^ll_Bit ), 2 ) = 1 ) ) Then
If Not Mod( Long( Value / 2^ll_Bit ), 2 ) > 0 Then
Value += 2^ll_Bit
End If
End If
Next
//////////////////////////////////////////////////////////////////////////////
//
// Function: of_GetBit
//
// Access: public
//
// Arguments:
// al_decimal Decimal value whose on/off value needs to be determined (e.g. 47).
// ai_bit Position bit from right to left on the Decimal value.
//
// Returns: boolean
// True if the value is On.
// False if the value is Off.
// If any argument's value is NULL, function returns NULL.
//
// Description: Determines if the nth binary bit of a decimal number is
// 1 or 0.
//
//////////////////////////////////////////////////////////////////////////////
//
// Revision History
//
// Version
// 5.0 Initial version
// 5.0.03 Fixed problem when dealing with large numbers (>32k)
// from "mod int" to "int mod"
//
//////////////////////////////////////////////////////////////////////////////
//
// 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.
//
//////////////////////////////////////////////////////////////////////////////
Boolean lb_null
//Check parameters
If IsNull(al_decimal) or IsNull(ai_bit) then
SetNull(lb_null)
Return lb_null
End If
//Assumption ai_bit is the nth bit counting right to left with
//the leftmost bit being bit one.
//al_decimal is a binary number as a base 10 long.
If Int(Mod(al_decimal / (2 ^(ai_bit - 1)), 2)) > 0 Then
Return True
End If
Return False
///////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
// Function: of_BitwiseXor
//
// 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 XOR operation (e.g. 27).
// If either argument's value is NULL, function returns NULL.
//
// Description: Performs a bitwise exclusive OR operation (al_Value1 XOR al_Value2),
// which exclusively ORs each bit of the values.
// (55 XOR 44) = 27
//
//////////////////////////////////////////////////////////////////////////////
//
// 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
// Perfor the XOR
For li_Cnt = 1 To 32
If (lb_Value1[li_Cnt] And Not lb_Value2[li_Cnt]) Or &
(Not lb_Value1[li_Cnt] And lb_Value2[li_Cnt]) Then
ll_Result = ll_Result + (2^(li_Cnt - 1))
End If
Next