Survey Tabulation > Advanced expressions > UNICOM Intelligence function library > Miscellaneous functions > BitNot
 
BitNot
Performs a bitwise NOT on a numeric value and returns the result.
Syntax
BitNot(Val)
Parameter
Val
Type: Long
Data value.
(return)
Type: Long
Ones-complement of Val.
Remarks
The return value is a number with only the bits set that are not set in Val. If the current data value is NULL, Val is 0 and the return value is -1.
This function is similar to using Not as a bitwise operator in Visual Basic.
Example
BitNot enables you to refer to all of the bits in a bit pattern apart from one specific bit or group of bits. This is particularly useful when you want to clear certain bits without affecting the other bits. Like the other bit functions, BitNot, is useful when working with properties that store a numeric value in which the bits are used to record true or false values that represent whether various flags have been set. Typically a type definition is used to define the various flags.
For example, the Element.Flag property in the MDM is used to record whether a category is one or more of various special category types, such as Other Specify, Don't know, or Exclusive (which means that the category is single-choice when it is used in a multiple response question). The values are defined in the CategoryFlagConstants type definition and because the Flag is used as a bit field, it can store more than one "value".
This mrScriptBasic example uses BitNot in combination with ="BitAnd to get a category’s flags, but without the bit pattern that corresponds to the flExclusive flag:
Dim ElemFlags

ElemFlags = BitAnd(MDM.Fields["remember"].Categories["Not_answered"].Flag, _
BitNot(CategoryFlagConstants.flExclusive))
See also
Miscellaneous functions