Bit.setfield() - Keithley 3700A Series Reference Manual

System switch/multimeter
Hide thumbs Also See for 3700A Series:
Table of Contents

Advertisement

Section 11: TSP command reference

bit.setfield()

This function overwrites a bit field at a specified index position.
Type
TSP-Link accessible
Function
No
Usage
result = bit.setfield(value, index, width, fieldValue)
result
value
index
width
fieldValue
Details
This function returns result, which is value with a field of bits overwritten, starting at index. The
index specifies the position of the least significant bit of value. The width bits starting at index
are set to fieldValue.
The least significant bit of value is at index position 1; the most significant bit is at index
position 32.
Before setting the field of bits, any fractional parts of value and fieldValue are truncated to form
integers.
If fieldValue is wider than width, the most significant bits of the fieldValue that exceed the
width are truncated. For example, if width is 4 bits and the binary value for fieldValue is 11110
(5 bits), the most significant bit of fieldValue is truncated and a binary value of 1110 is used.
Example
testResult = bit.setfield(15, 2, 3, 5)
print(testResult)
Also see
Bit manipulation and logic operations
bit.get()
(on page 11-11)
bit.set()
(on page 11-13)
bit.getfield()
(on page 11-12)
11-14
Affected by
Result of the bit manipulation
Specified number
One-based bit position in value to set (1 to 32)
The number of bits to include in the field (1 to 32)
Value to write to the field
(on page 9-21)
Series 3700A System Switch/Multimeter Reference Manual
Where saved
Default value
The binary equivalent of decimal 15 is 1111. After
overwriting it with a decimal 5 (binary 101) at index
position 2, the returned value is decimal 11 (binary
1011).
Output:
1.10000e+01
3700AS-901-01 Rev. D/June 2018

Advertisement

Table of Contents
loading

Table of Contents