set_field¶
-
Math.Bin.
set_field
(word, value, mask=255)¶ Set a value into a bit field
- Test::
In [5]: bin(set_field(int(“101010101010”,2), int(“010101”,2), mask=”11:6”)) DEBUG:Math.Bin:set_field: word: 0b101010101010 DEBUG:Math.Bin:set_field: value: 0b10101 DEBUG:Math.Bin:set_field: mask: 0b111111000000 DEBUG:Math.Bin:set_field: masked word: 0b101010 DEBUG:Math.Bin:set_field: shifted value: 0b10101000000 Out[5]: ‘0b10101101010’
:param word : word to be modified :type word : int
:param value : value to be inserted :type value : int
:param mask : bitmask; default 255 (‘0b11111111’), l.s.byte :type mask : int
- Returns
int