| Package | core |
| Class | public class bit |
| Inheritance | bit Object |
Practical infos to convert to bits, hex and decimal
| Hex | Dec | Binary |
|---|---|---|
| 0 | 0 | 0000 |
| 1 | 1 | 0001 |
| 2 | 2 | 0010 |
| 3 | 3 | 0011 |
| 4 | 4 | 0100 |
| 5 | 5 | 0101 |
| 6 | 6 | 0110 |
| 7 | 7 | 0111 |
| 8 | 8 | 1000 |
| 9 | 9 | 1001 |
| A | 10 | 1010 |
| B | 11 | 1011 |
| C | 12 | 1100 |
| D | 13 | 1101 |
| E | 14 | 1110 |
| F | 15 | 1111 |
| Property | Defined 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 | ||
| Method | Defined 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 | ||
[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 | ||
| hexlength | property |
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)
public function get hexlength():uint| length | property |
length:uint [read-only] Returns the length of the bit(s).
public function get length():uint| bit | () | Constructor |
public function bit(value:uint = 0)value:uint (default = 0) |
| clear | () | method |
public function clear():voidClears all the bits.
| get | () | method |
public function get(index:uint):uintGets the bit at the index position.
Parameters
index:uint |
uint |
| parse | () | method |
public static function parse(value:String, radix:uint = 2):bitParses a string into bits.
Parameters
value:String | |
radix:uint (default = 2) |
bit |
| pop | () | method |
public function pop():uintRemoves the last bit and returns it.
Returnsuint |
| push | () | method |
public function push(... bits):voidAdds one or more bits to the current bit.
Parameters
... bits |
| reverse | () | method |
public function reverse(mask:uint = 0):voidReverse the order of bits.
Parameters
mask:uint (default = 0) |
| rotateLeft | () | method |
public function rotateLeft(bits:uint = 1, mask:uint = 0):voidRotates 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):voidRotates 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):voidSets the bit at the index position.
Parameters
index:uint |
| shift | () | method |
public function shift():uintRemoves the first bit and returns it.
Returnsuint |
| toggle | () | method |
public function toggle(index:uint):voidToggles the bit at the index position.
Parameters
index:uint |
| toString | () | method |
public function toString(radix:Number = 2, padding:Boolean = true):StringReturns the String representation of the object.
Parameters
radix:Number (default = 2) | |
padding:Boolean (default = true) |
String — the String representation of the object.
|
| unset | () | method |
public function unset(index:uint):voidClears the bit at the index position.
Parameters
index:uint |
| valueOf | () | method |
public function valueOf():uintReturns the primitive value of the object.
Returnsuint — the primitive value of the object.
|
| MAX | Constant |
public static const MAX:uint = 32| MIN | Constant |
public static const MIN:uint = 0