Utilities for working with binary data and bit manipulation in Dart.
This library supports an
Integral data type for fluent bit manipulation:
print(uint8.toBinaryPadded(196)); // '11000100'
Because of Dart's ability to do advanced inlining in both the Dart VM and
dart2js, this library should perform well and be extremely easy to use for most
use cases. For example, it's used in an
This library has a combination of top-level methods, and instance methods of
Integral data types (see below). For example there are two ways
to clear (set to
0) a bit:
// Sets the 0th bit in an (int) bits to 0 bits = clearBit(bits, 0)
However, this will not do range validation. Use
// Sets the 0th bit in a uint32 to 0. // In dev-mode, if either bits or `n` is out of range it throws. bits = uint32.clearBit(bits, 0);
Integral data types
See the dartdocs for more about the API.
Utilities for common binary and bit operations.