287 questions
1
vote
1
answer
99
views
How to get `bitarray` module in Python 3.11, iPadOS 17.6?
I wanted to use the bitarray module. I typed the command $ pip3 install bitarray. It was successfully installed, but it reported an error when I tried to import it.
Code:
import bitarray
Error ...
-3
votes
1
answer
72
views
Strange behavior with lists of Python bitarrays and the in-place XOR operation ^=
I've managed to isolate (what I perceive to be) a strange relationship between lists of bitarrays and the XOR operation in Python.
Here is my minimal example:
ls = [bitarray('0'), bitarray('0')]
ls[0] ...
0
votes
1
answer
184
views
Bitarray representation of Connect Four for Zobrist hashing
This began primarily as a though experiment on how best to do this, but I've gone too deep to just forget about it.
The question I began with was: How is it best to save a game tree of Connect Four ...
2
votes
0
answers
88
views
How to convert BitArray to Data?
I am using BitArray in my project and need to convert it to Data to pass it to writeValue(_:for:type:). Did not find corresponding method in BitArray, so should I replace BitArray with [UInt8]?
0
votes
1
answer
129
views
Efficient bitarray operations in Python
I'm implementing a class for handling arrays of bit values in Python. So far, here is what I did:
class Bitarray:
""" Representation of an array of bits.
:param bits: the list ...
0
votes
1
answer
110
views
How can I convert byte to fixed size (size = 8) bitArray
I want Convert Byte to fixed size (size = 8) bit array
Want Behavior:
var bits = GetBits(0x00); // returned [0,0,0,0,0,0,0,0]
bits = GetBits(0x01); // returned [1,0,0,0,0,0,0,0]
bits = GetBits(0x0A);...
1
vote
0
answers
116
views
Read non-byte-aligned value from byte array
I am trying to read a n-bit (n <= 8) long value from a byte[]. This value may not be aligned to the start/end of any byte or may span two bytes. To make this more clear, please see the following ...
2
votes
3
answers
98
views
How do you increment a bit of a bit-array from a position in array?
I would like to (modulo) increment a particular bit of a bit-array. How do you do that in Common Lisp ?
For example, I want to increment the value of bit 3 in bit-array #*0001
(The bit 3 has the value ...
1
vote
0
answers
76
views
Inserting different type of values into a Bitarray
I have a bit array that represents a data protocol, 1024 bytes. The range of the fields go from very small, to int32s in size.
For example, ProtoID = bits 0-3, Source = bits 4-6, Value1 = bits 7-14, ...
1
vote
1
answer
276
views
Is there an easy way to merge several BitArrays?
I have several BitArrays that will need to be merged to into 48 byte structure.
BitArray a1 = new (3);
BitArray a2 = new (11);
BitArray a3 = new (14);
//And so on
//Do bit manipulation, etc with the ...
0
votes
0
answers
138
views
C# BitArray save to or read from SQL Server Binary
Current, converting c# BitArray to byte[] then save to SQL Server. Is there any way to save it directly?
var byteArray = new byte[625];
bitArray.CopyTo(byteArray, 0);
Save(byteArray);
As reading from ...
2
votes
2
answers
192
views
Python efficient assigning of even and odd bits to a bitstring/bit_array
I receive serialized DDR data from a setup with 8 chips. Due to the way the readout is implemented in hardware, the data that is received by the computer has the following structure:
bits 0 and 1 of ...
0
votes
0
answers
93
views
Converting BitArray to Binary
I'm trying to make a simple compressor (I think the algorithm is done) but when trying to get read the bytes from a file and converting them to binary i'm not able to do it.
I have a BitArray that ...
1
vote
0
answers
70
views
how to return represent binary 1 and 0 using BitArray in python
i have audio file and i was represent the file with 1 and 0 using bitarray. but i want to get the result. when i return the variable, the result i got is not same as the text file was made. so how to ...
1
vote
0
answers
251
views
How to initialize a BitArray from a byte [duplicate]
In C#
BitArray ba = new BitArray((byte)70);
I expect that ba should be equal to {0,1,1,1,0,0,0,0}.
Instead I get a bunch of zero, (sorry did not count them I will post back if I need to).
I have ...