BinaryPolynomial.fromHex constructor

BinaryPolynomial.fromHex(
  1. String digits
)

Creates a binary polynomial from hexadecimal digits.

Underscores are accepted as separators. The inferred width is four times the number of hexadecimal digits. Use BinaryPolynomial.fromRadixString to specify an exact width that is not a multiple of four.

Implementation

factory BinaryPolynomial.fromHex(String digits) {
  final compressed = digits.replaceAll('_', '');
  if (compressed.isEmpty) {
    throw RohdHclException(
        'Hexadecimal polynomial digits must not be empty.');
  }
  return BinaryPolynomial.fromRadixString(
      "${compressed.length * 4}'h$digits");
}