Difference between revisions of "BIT"

From QB64 Wiki
Jump to navigation Jump to search
imported>Clippy
m
imported>Clippy
m
Line 1: Line 1:
The _BIT datatype can hold only 0 and -1.  
+
The _BIT datatype can hold only values of 0 (bit off) and -1 (bit on).  
  
  
Line 11: Line 11:
 
* If you set the variable to any other number then the least significant bit of that number will be set as the variables number, if the bit is 1 (on) then the variable will be -1 and if the bit is 0 (off) then the variable will be 0.
 
* If you set the variable to any other number then the least significant bit of that number will be set as the variables number, if the bit is 1 (on) then the variable will be -1 and if the bit is 0 (off) then the variable will be 0.
  
* A [[_UNSIGNED]] _BIT can hold 0 or 1 instead of 0 and -1, the rest is the same.
+
* A [[_UNSIGNED]] _BIT can hold 0 or 1 instead of 0 and -1.
  
 
*The least significant bit is the last bit on a string of bits (11111) since that bit will only add 1 to the value if set. The most significant bit is the first bit on a string of bits and changes the value more dramatically (significantly) if set on or off.
 
*The least significant bit is the last bit on a string of bits (11111) since that bit will only add 1 to the value if set. The most significant bit is the first bit on a string of bits and changes the value more dramatically (significantly) if set on or off.
  
*The _BIT datatype can be succesfully used as a boolean (TRUE or FALSE) and it requires minimal amount of memory (the lowest amount possible actually, one byte can hold 8 bits).
+
*The _BIT datatype can be succesfully used as a [[Boolean]] (TRUE or FALSE) and it requires minimal amount of memory (the lowest amount possible actually, one byte can hold 8 bits).
  
  
  
  
''See also:'' [[_BYTE]], [[_DEFINE]], [[_UNSIGNED]], [[DIM]], [[Binary]]
+
''See also:'' [[_BYTE]], [[_DEFINE]], [[_UNSIGNED]], [[DIM]], [[Binary]], [[Boolean]]
  
  

Revision as of 00:52, 4 October 2009

The _BIT datatype can hold only values of 0 (bit off) and -1 (bit on).


Syntax: _DEFINE variable AS [ _UNSIGNED ] _BIT


More information:

  • If you set the variable to any other number then the least significant bit of that number will be set as the variables number, if the bit is 1 (on) then the variable will be -1 and if the bit is 0 (off) then the variable will be 0.
  • A _UNSIGNED _BIT can hold 0 or 1 instead of 0 and -1.
  • The least significant bit is the last bit on a string of bits (11111) since that bit will only add 1 to the value if set. The most significant bit is the first bit on a string of bits and changes the value more dramatically (significantly) if set on or off.
  • The _BIT datatype can be succesfully used as a Boolean (TRUE or FALSE) and it requires minimal amount of memory (the lowest amount possible actually, one byte can hold 8 bits).



See also: _BYTE, _DEFINE, _UNSIGNED, DIM, Binary, Boolean



Navigation:

Go to Keyword Reference - Alphabetical

Go to Keyword Reference - By usage