Packagecore
Classpublic class bit
Inheritancebit Inheritance Object

The bit class allow you to manipulate the bits of an unsigned integer.

Practical infos to convert to bits, hex and decimal

Hex Dec Binary
0 00000
1 10001
2 20010
3 30011
4 40100
5 50101
6 60110
7 70111
8 81000
9 91001
A101010
B111011
C121100
D131101
E141110
F151111



Public Properties
 PropertyDefined By
  hexlength : uint
[read-only] Returns the hexadecimal length of the bit(s).
bit
  length : uint
[read-only] Returns the length of the bit(s).
bit
Public Methods
 MethodDefined By
  
bit(value:uint = 0)
bit
  
clear():void
Clears all the bits.
bit
  
get(index:uint):uint
Gets the bit at the index position.
bit
  
parse(value:String, radix:uint = 2):bit
[static] Parses a string into bits.
bit
  
pop():uint
Removes the last bit and returns it.
bit
  
push(... bits):void
Adds one or more bits to the current bit.
bit
  
reverse(mask:uint = 0):void
Reverse the order of bits.
bit
  
rotateLeft(bits:uint = 1, mask:uint = 0):void
Rotates the bit on the left by an amount of bits (default 1) over a mask (default 0).
bit
  
rotateRight(bits:uint = 1, mask:uint = 0):void
Rotates the bit on the right by an amount of bits (default 1) over a mask (default 0).
bit
  
set(index:uint):void
Sets the bit at the index position.
bit
  
shift():uint
Removes the first bit and returns it.
bit
  
toggle(index:uint):void
Toggles the bit at the index position.
bit
  
toString(radix:Number = 2, padding:Boolean = true):String
Returns the String representation of the object.
bit
  
unset(index:uint):void
Clears the bit at the index position.
bit
  
valueOf():uint
Returns the primitive value of the object.
bit
Public Constants
 ConstantDefined By
  MAX : uint = 32
[static]
bit
  MIN : uint = 0
[static]
bit
Property Detail
hexlengthproperty
hexlength:uint  [read-only]

Returns the hexadecimal length of the bit(s).

bit length in hexadecimal are multiple of 4, for ex: the number 1 gives 0001 bits and will have a length of 1 (1 bit) and a hexlength of 4 (4 bits)


Implementation
    public function get hexlength():uint
lengthproperty 
length:uint  [read-only]

Returns the length of the bit(s).


Implementation
    public function get length():uint
Constructor Detail
bit()Constructor
public function bit(value:uint = 0)



Parameters
value:uint (default = 0)
Method Detail
clear()method
public function clear():void

Clears all the bits.

get()method 
public function get(index:uint):uint

Gets the bit at the index position.

Parameters

index:uint

Returns
uint
parse()method 
public static function parse(value:String, radix:uint = 2):bit

Parses a string into bits.

Parameters

value:String
 
radix:uint (default = 2)

Returns
bit
pop()method 
public function pop():uint

Removes the last bit and returns it.

Returns
uint
push()method 
public function push(... bits):void

Adds one or more bits to the current bit.

Parameters

... bits

reverse()method 
public function reverse(mask:uint = 0):void

Reverse the order of bits.

Parameters

mask:uint (default = 0)

rotateLeft()method 
public function rotateLeft(bits:uint = 1, mask:uint = 0):void

Rotates the bit on the left by an amount of bits (default 1) over a mask (default 0).

When the mask is 0, we take the minimum length of the bit for ex: var b:bit = new bit( 8 ); //1000 b.rotateLeft(); //0001 But you can force the mask to be any value from 0 to 32 for ex: var b:bit = new bit( 8 ); // 1000 b.rotateLeft( 1, 8); //00010000 here we rotated 1 bit to the left over a 8bits mask

Parameters

bits:uint (default = 1)
 
mask:uint (default = 0)

rotateRight()method 
public function rotateRight(bits:uint = 1, mask:uint = 0):void

Rotates the bit on the right by an amount of bits (default 1) over a mask (default 0).

Parameters

bits:uint (default = 1)
 
mask:uint (default = 0)

set()method 
public function set(index:uint):void

Sets the bit at the index position.

Parameters

index:uint

shift()method 
public function shift():uint

Removes the first bit and returns it.

Returns
uint
toggle()method 
public function toggle(index:uint):void

Toggles the bit at the index position.

Parameters

index:uint

toString()method 
public function toString(radix:Number = 2, padding:Boolean = true):String

Returns the String representation of the object.

Parameters

radix:Number (default = 2)
 
padding:Boolean (default = true)

Returns
String — the String representation of the object.
unset()method 
public function unset(index:uint):void

Clears the bit at the index position.

Parameters

index:uint

valueOf()method 
public function valueOf():uint

Returns the primitive value of the object.

Returns
uint — the primitive value of the object.
Constant Detail
MAXConstant
public static const MAX:uint = 32

MINConstant 
public static const MIN:uint = 0