| **Navigation:**  [[introduction.htm|Language Reference]] > 13 - Built-in Functions >====== BAND (return bitwise AND) ====== | [[atan return arctangent .htm|{{btn_prev_n.gif|Previous page}}]][[introduction.htm|{{btn_home_n.gif|Return to chapter overview}}]][[beep sound tone on speaker .htm|{{btn_next_n.gif|Next page}}]] | | || **BAND(**//value//,//mask//**)** {{blk2blue.jpg|blk2blue.jpg}} | **BAND** | Performs bitwise AND operation. | | //value// | A numeric constant, variable, or expression for the bit //value// to be compared to the bit //mask//. The //value// is converted to a LONG data type prior to the operation, if necessary. | | //mask// | A numeric constant, variable, or expression for the bit //mask//. The //mask// is converted to a LONG data type prior to the operation, if necessary. | The **BAND** procedure compares the //value// to the //mask//, performing a Boolean AND operation on each bit. The return value is a LONG integer with a one (1) in the bit positions where the //value// and the //mask// both contain one (1), and zeroes in all other bit positions. BAND is usually used to determine whether an individual bit, or multiple bits, are on (1) or off (0) within a variable. | **Return Data Type:** | LONG | **Example:** **!BAND(0110b,0010b) returns 0010b !0110b = 6, 0010b = 2** **RateType  BYTE                 !Type of rate** **Female    EQUATE(0001b)        !Female mask** **Male      EQUATE(0010b)        !Male mask** **Over25    EQUATE(0100b)        !Over age 25 mask** ** CODE** ** IF ****BAND****(RateType,Female)|     !If female** **   AND ****BAND****(RateType,Over25)   ! and over 25** **  DO BaseRate                  !use base premium** ** ELSIF ****BAND****(RateType,Male)     !If male** **  DO AdjBase                   !adjust base premium** ** END   ** **See Also:** [[bor return bitwise or .htm|BOR]] [[bxor return bitwise exclusive or .htm|BXOR]] [[bshift return shifted bits .htm|BSHIFT]]