Qu

crc_check

Builtin index · Signal processing

result = crc_check(bits, polynomial)

Input: bits, polynomial · Output: result

What it is

bits: a message with its crc remainder already appended; polynomial as for crc. Divides the whole codeword and reports whether the remainder is all zeros.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = crc_check(bits, polynomial)
bits —bits: a message with its crc remainder already appended.
polynomial —polynomial as for crc.
result —
Returns a Bool. (Added in v0.3.0.)

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

bits = [0, 1, 1, 0, 1, 0, 0, 1]
syms = qam_modulate(bits, 16)             # 2 symbols on the odd-integer grid

print(qam_demodulate(syms, 16))           # back to the same 8 bits


print(hamming74_encode([1, 0, 1, 1]))     # [0, 1, 1, 0, 0, 1, 1]

r = hamming74_decode([0, 1, 1, 0, 1, 1, 1])   # bit 5 flipped in transit

print("{r.data} corrected={r.corrected} at {r.positions}")

m = [1, 1, 0, 1]
print(crc(m, 11))                         # [0, 0, 1] -- x^3 + x + 1

print(crc_check([1, 1, 0, 1, 0, 0, 1], 11))   # true

output
[0, 1, 1, 0, 1, 0, 0, 1]
[0, 1, 1, 0, 0, 1, 1]
[1, 0, 1, 1] corrected=true at [5]
[0, 0, 1]
true

from signal-processing

How it works

crc_check(bits, polynomial) — bits is a message with its CRC already appended; true when the remainder is zero.

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.