![background image](http://html2.mh-extra.com/html/keithley/sourcemeter-2601/sourcemeter-2601_reference-manual_4018913273.webp)
2600S-901-01 Rev. C / January 2008
Return to
12-13
Series 2600 System SourceMeter® Instruments Reference Manual
Section 12: Instrument Control Library
Usage
value = bit.get(value1, index)
value1
Given
number.
index
Index position of the bit to be retrieved (1 to
32).
value
Returned weighted value of the bit.
Remarks
• This function returns the value of the bit in
value1
at the given index. This is the same
as returning
value1
with all other non-indexed bits set to zero.
• Prior to retrieving the indexed bit, 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.
• If the indexed bit for the number is set to 0, the result will be 0.
• See “
for more information.
Also see
,
,
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.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 “
for more information.
Also see
,
,
,
,
Example
The binary equivalent of decimal 13 is 1101. The field at
index2
and
width3
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.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.
Remarks
• This function returns
value
, which is
value1
with the indexed bit set.
The
index
m
ust
be a value between 1 and 32. The least significant bit of the given number has an index
of 1 and the most significant bit has an index of 32.
• Any fractional part of
value1
will be truncated to make it an integer.
• See “
for more information.
Also see
,
,
,