Models 707B and 708B Switching Matrix Reference Manual
Section 7: TSP command reference
707B-901-01 Rev. B / January 2015
7-15
Usage
result
= bit.test(
value
,
index
)
result
Result of the bit manipulation
value
Specified number
index
One-based bit position within value to test (1 to 32)
Details
This function returns
result
, which is the result of the tested bit.
The least significant bit of
value
is at
index
position 1; the most significant bit is at
index
position
32.
If the indexed bit for
value
is 0,
result
is
false
. If the bit of
value
at
index
is 1, the returned
value is
true
.
If
index
is bigger than the number of bits in
value
, the result is
false
.
Example
testResult = bit.test(10, 4)
print(testResult)
The binary equivalent of decimal 10 is 1010.
Testing the bit at
index
position 4 returns a
Boolean value of
true
.
Output:
true
Also see
Bit manipulation and logic operations
(on page 5-4)
(on page 7-11)
(on page 7-11)
(on page 7-13)
(on page 7-15)
bit.toggle()
This function toggles the value of a bit at a specified index position.
Type
TSP-Link accessible
Affected by
Where saved
Default value
Function
No
Usage
result
= bit.toggle(
value
,
index
)
result
Result of the bit manipulation
value
Specified number
index
One-based bit position within
value
to toggle (1 to 32)
Details
This function returns
result
, which is the result of toggling the bit
index
in
value
.
Any fractional part of
value
is truncated to make it an integer. The returned value is also an integer.
The least significant bit of
value
is at
index
position 1; the most significant bit is at
index
position
32.
The indexed bit for
value
is toggled from 0 to 1, or 1 to 0.