Model 2601B-PULSE System SourceMeter Instrument Reference Manual Section 11: TSP command reference
2601B-PULSE-901-01A April 2020 11-13
bit.getfield()
This function returns a field of bits from the value starting at the specified index position.
Usage
result = bit.getfield(value, index, width)
Result of the bit manipulation
One-based bit position within value to get (1 to 32)
The number of bits to include in the field (1 to 32)
Details
A field of bits is a contiguous group of bits. This function retrieves a field of bits from value starting
at index.
The index position is the least significant bit of the retrieved field. The number of bits to return is
specified by width.
The least significant bit of value is at index position 1; the most significant bit is at
index position 32.
Example
myResult = bit.getfield(13, 2, 3)
print(myResult)
The binary equivalent of decimal 13 is 1101.
The field at index position 2 and width 3 consists of the
binary bits 110. The returned value is decimal 6 (binary 110).
Output:
6.00000e+00
Also see
Bit manipulation and logic operations (on page 9-4)
bit.get() (on page 11-12)
bit.set() (on page 11-14)
bit.setfield() (on page 11-15)