get_field¶
-
Math.Bin.
get_field
(word, mask=255)¶ Extract a value from a range of bits (bit field)
- Test::
In [5]: get_field(int(“101010010101”,2), mask=”11:6”) DEBUG:Math.Bin:get_field: word: 0b101010010101 DEBUG:Math.Bin:get_field: mask: 0b111111000000 DEBUG:Math.Bin:get_field: extracted: 0b101010000000 DEBUG:Math.Bin:get_field: shifted: 0b101010 Out[5]: 42
:param value : word to be masked :type value : int
:param mask : bitmask; default 255 (‘0b11111111’), l.s.byte :type mask : int
- Returns
int