12-16 Instrument Control Library Series 2600 System SourceMeters Reference Manual
2600S-901-01 Rev. A / May 2006 Return to Section 12 topics
Also see bit.clear, bit.getfield, bit.set, bit.setfield, bit.test, bit.toggle
Example
The binary equivalent of decimal 10 is 1010. Getting the bit at index position 4 will
return decimal
value 8:
value = bit.get(10, 4)
print(value)
Output: 8.000000e+00
bit.getfield
Function Returns a field of bits starting at a given index position.
Usage
value = bit.getfield(value1, index, width)
value1 Given number.
index Index position of the first bit; 1 to (33 – width).
width Field width – number of bits to be included in the field; 1 to 24.
value Returned value of the bit field.
Remarks
• A field of bits is a contiguous group of bits. This function retrieves a field of bits from
value1 starting at the given index position. The index position is the least
significant bit of the retrieved field. The number of bits to return is given by
width.
• Prior to retrieving the field of bits, any fractional part of the given number will be
truncated to make it an integer.
• The least significant bit of the given number has an index of 1 and the most
significant bit has an index of 32.
• See “Logic and bit operations” on page 12-13 for more information.
Also see bit.clear, bit.get, bit.set, bit.setfield, bit.test, bit.toggle
Example
The binary equivalent of decimal 13 is 1101. The field at index 2 and width 3 consists
of the binary bits 110. The returned
value will be decimal 6 (binary 110):
value = bit.getfield(13, 2, 3)
print(value)
Output: 6.000000e+00
bit.set
Function Sets a bit at a given index position.
Usage
value = bit.set(value1, index)
value1 Given number.
index Index position of the bit to be set (1 to 32).
value Returned value of the new number.