Documentation

Complexity.Computability.Machines.Turing.MultiTape.Encodings.IntBinary

Binary sign-magnitude integers #

encIntBin encodes an integer by a sign bit, true for negative integers, followed by the binary digits of its magnitude (Turing.MultiTapeTM.encNat), least significant first. The magnitude is not framed: the sign is a single leading bit, the digits are the rest of the word, and the magnitude is the tail of the code, so the binary natural arithmetic applies to it directly. A negative integer has a nonzero magnitude, so zero has the single code [false]. An integer z occupies Nat.size z.natAbs + 1 bits. The unary integers Turing.MultiTapeTM.encInt index tape positions; this encoding carries values whose magnitude is exponential in their length.

Main definitions #

Main results #

Integers in binary sign-magnitude form: the bit z < 0 followed by the binary digits of the magnitude z.natAbs, least significant first. Zero is encoded as [false] only.

Instances For

    The code of an integer has one sign bit and the binary length of its magnitude.