SetBit
Result = SetBit(Value, BitNo)
 
Parameters:

    Value = An integer value
    BitNo = The bit you want to set (0 = least significant bit)
Returns:

    Result
 

      SetBit sets a specified bit of a given state (on/off). Bits range between 0 and 31. 0 being the least significant bit (LSB), 31 is the most significant bit (MSB).



FACTS:


      * If the specified bit is already set SetBit will not change it.

      * SetBit is equivalent of Result=Value or (2 ^ BitNo)



Mini Tutorial:


      Showing the effect of SetBit

  
; Set the bits 0 to 7 of the value 0 and
; display only these 8 bits using the Right$ function
  For i = 0 To 7
     Print Right$(Bin$(SetBit(0,i),8)
  Next i
  
; Display the Screen and wait for the user to press a key
  Sync
  WaitKey
  



This example would output.

  
  00000001
  00000010
  00000100
  00001000
  00010000
  00100000
  01000000
  10000000
  


 
Related Info: And | ClearBit | Or | SwapBit | TestBit | Xor :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com