toString method

  1. @override
String toString ()
override

returns the String representation of the BitData. It contains the binary representation as well as the integer.

Implementation

@override
String toString() {
  List<int> result = [];
  String r = "";

  int temp = _source;

  while (temp > 0) {
    result.add(temp % 2);
    temp = temp ~/ 2;
  }

  int i = 0;

  for (int bit in result.reversed) {
    r += bit.toString();
    i++;

    if (i % 4 == 0) r += " ";
  }

  r += "($_source)";

  return r;
}