0

I want to create a byte array (it can be fixed size) and set/clear specific bits inside this array given the position of the bits

For example we have a byte array of length 16 (128bits). And I want to set the bit no 100, 110, 16, and 34.

Can I do that without math or logic operations? Like using any library or function?

MrBit
  • 290
  • 4
  • 20
  • 1
    The math or logic operations required are so simple that nobody dare to write a function or library for that. Also, you should know that in Python, integers have infinite length. So you do not need an array to store 128 bits. – user3435121 Nov 19 '22 at 17:37
  • @dskrypa Looks interesting! Thanks – MrBit Nov 19 '22 at 17:39
  • @user3435121 I did not know that! Thanks! Seems like my problem is solved. – MrBit Nov 19 '22 at 17:41

0 Answers0