a.testBit n is true iff the n-th bit (starting from the LSB) in the binary representation
of a is active. If the size of a is less than n, this evaluates to false.
Instances For
n.oneBits 0 is the list of indices of active bits in the binary representation of n.
Instances For
Left-shift the binary representation of a PosNum.
Instances For
Right-shift the binary representation of a PosNum.
Instances For
Left-shift the binary representation of a Num.
Instances For
Right-shift the binary representation of a Num.
Instances For
a.testBit n is true iff the n-th bit (starting from the LSB) in the binary representation
of a is active. If the size of a is less than n, this evaluates to false.
Instances For
n.oneBits is the list of indices of active bits in the binary representation of n.
Instances For
Instances For
Alternative representation of integers using a sign bit at the end.
The convention on sign here is to have the argument to msb denote
the sign of the MSB itself, with all higher bits set to the negation
of this sign. The result is interpreted in two's complement.
13 = ..0001101(base 2) = nz (bit1 (bit0 (bit1 (msb true)))) -13 = ..1110011(base 2) = nz (bit1 (bit1 (bit0 (msb false))))
As with Num, a special case must be added for zero, which has no msb,
but by two's complement symmetry there is a second special case for -1.
Here the Bool field indicates the sign of the number.
0 = ..0000000(base 2) = zero false -1 = ..1111111(base 2) = zero true
Instances For
The SNum representation uses a bit string, essentially a list of 0 (false) and 1 (true) bits,
and the negation of the MSB is sign-extended to all higher bits.
Add a bit at the end of a NzsNum.
Instances For
Instances For
Add an inactive bit at the end of a NzsNum. This mimics PosNum.bit0.
Instances For
Add an active bit at the end of a NzsNum. This mimics PosNum.bit1.
Instances For
Add a bit at the end of a SNum. This mimics NzsNum.bit.
Instances For
SNum.testBit n a is true iff the n-th bit (starting from the LSB) of a is active.
If the size of a is less than n, this evaluates to false.
Instances For
SNum.czAdd a b n is n + a - b (where a and b should be read as either 0 or 1).
This is useful to implement the carry system in cAdd.
Instances For
a.bits n is the vector of the n first bits of a (starting from the LSB).