287 questions
1
vote
1
answer
101
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
192
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
92
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
133
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
120
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
120
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
103
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
79
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
281
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
143
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
195
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
97
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
74
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
252
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 ...
0
votes
0
answers
60
views
ValueError: reached end of bitarray
I am building a compression algorithm that takes a tab-delimited file, converts each column to binary (bitarray) using huffman coding, then converts the bitarray to hexadecimal format (ba2hex). This ...
2
votes
1
answer
3k
views
How to read a single bit from a Buffer in TypeScript?
I am aware that a similar question has already been asked before (see How to read a single bit buffer in node), but it seems none of the answers are helful. The first comment that has been accepted, ...
1
vote
1
answer
316
views
Julia BitArray with 128 Bits
I need a Julia BitArray-like object that can encode more than 64 bits, say 128 bits. Does a simple replacement of UInt64 with UInt128 in bitarray.jl work?
1
vote
2
answers
650
views
How to properly write and read BitArray objects?
I have an issue. I tryed to save my BitArray object into file. After that I want to read it and get the same BitArray object what I saved earlier. But result is not same with input.
from bitarray ...
0
votes
2
answers
179
views
Check if N(large) bits are set
I want to check if any of the 1024 bits (128 bytes) are set. If all are clear, then I want to do something. Is it possible to do this quickly, i.e one instruction or do I have to loop through my ...
0
votes
1
answer
205
views
Convert bitarray to image
I have large bitarray as a start 100 000 000 bits i.e. 10000x10000.
What is the most feasible and economic way to convert it to scaled down version may be 1000x1000, by preserving best the dot|1 ...
0
votes
1
answer
289
views
Direct access to bitarray from cython
I can access bitarray bits with slice syntax..
b = bitarray(10)
b[5]
How would I access an element directly ?
Similar to the way I can directly access array elements:
ary.data.as_ints[5]
instead of :...
0
votes
1
answer
123
views
Transforming Bitarray into to list of power of 2's
I am trying to conver Bitarray into an array of corresponding decimal values if the bit is 1.
The code I write is below but i don't want to use for loop. Is there a way around to avoid loop?
int right ...
1
vote
1
answer
358
views
bitarray to byte array possible endian issues
I am wanting to store a sequence of bool values in azure blob storage along with a separate map file (a comma separated list of names in the same order as the bool values).
As efficiency and storage ...
0
votes
0
answers
33
views
Copying C# BitArray to byte[] produces incorrect result [duplicate]
As mentioned in the title, when I copy a BitArray to a byte array, the resulting byte array contains the correct values but in the wrong order.
So here is a small snippet of code I created that ...
1
vote
1
answer
164
views
Trying to pipx install Brownie without installing MS Visual C++
I'm currently trying to install Brownie for Python on my Windows machine using pipx:
pipx install eth-brownie.
When I run this command, there is a "fatal error" message saying:
pip failed to ...
1
vote
1
answer
154
views
Trying to remove a value from a set which is constructed using bitvector
Im trying to remove value from a set but can't get it to work
this is the struct
struct set {
int capacity;
int size;
char *array;
};
This is how i insert the values in to the set
void set_insert(...
0
votes
1
answer
606
views
How do I add bits to a MemoryStream
So I've been trying to add bits of a value to a MemoryStream but the issue is I have no idea how. I've seen that it's used for performance when it comes to networking.
I know I want a function that ...
0
votes
1
answer
328
views
How do I install the bitarray package onto Python in Visual Studio 2019?
I followed the instructions here: Step 5: Install packages in your Python environment
and that seemed to work, but I get this error when I run it:
0
votes
0
answers
72
views
why do I keep getting this error during web3py module installation
I'm trying to install web3 module for python and I keep getting that is connected to bitarray. hare's the error I keep getting:
error
ERROR: Command errored out with exit status 1:
command: '...
2
votes
1
answer
489
views
Creating Bit Array in Powershell/C# from integers
I'm trying to reverse engineer a game database and have come to a roadblock.
I can load all the tables/fields/records , however I'm stuck when it comes to converting the record values to hex or bits
...
3
votes
1
answer
1k
views
What is the best way to store a large list of Boolean values in x86 assembly?
Lately I have been working with large arrays that are full of boolean values. Currently, I store them in the .bss section with a .space directive, which allows me to create arrays of bytes. However, ...
2
votes
1
answer
2k
views
How to utilize every bit of a bytearray in python
I have a bytearray like this:
a=bytearray([False]*size)
I want to store the False value not as a byte but a bit in the byte array; I care about the memory. Is there anyway I can do that? As using 8 ...
1
vote
2
answers
2k
views
How to convert bitarray data to string in Python
I have binary code in bitarray. I want to display the contents of the bitarray, as a string. How can I fix the code to display the content.
from bitarray import bitarray
data = bitarray('010101')
...
0
votes
0
answers
64
views
Order of bytes after BitArray to byte[] conversion
I'm, trying to figure out bytes order after conversion from BitArray to byte[].
Firstly, here is the BitArray content:
BitArray encoded = huffmanTree.Encode(input);
foreach (bool bit in encoded)
{
...
0
votes
0
answers
67
views
BitArray to byte[] wrong conversion
I am implementing Huffman Encoding, the Huffman algorithm works well, the thing is:
When I'm trying to convert BitArray to byte[] using
BitArray encoded = huffmanTree.Encode(input); // The encoding ...
7
votes
1
answer
2k
views
"Failed to build bitarray cytoolz lru-dict" while Installing Web3
After running the command in Windows 10 - python -m pip install web3 the following error appears - "Failed to build bitarray cytoolz lru-dict".
I resolved the issue by installing Visual ...
0
votes
0
answers
890
views
Redis Database Implementation with Java
Good Day,
I have a project to do where I have to create a database with Redis bit arrays data type and write a Java code to access the database with a GUI drop down menu. I was able to implement the ...
1
vote
0
answers
217
views
What is the time complexity of BitArray initilized to 0?
when creating a BitArray and initializing all of its value to 0 (via constructor, new BitArray(size, false);) what is the time complexity of such operation? It's not in the docs about collections.
...
1
vote
1
answer
132
views
C# Write 8 bits packet divided in 3 ints
I need to write a 8 bit packet, that includes 3 ints, in this division:
int1 = 1 bit
int2 = 1 bit
int3 = 6 bit
I don't know how to do that. I can write some 4 bytes packets, using this function which ...
2
votes
2
answers
508
views
Convert BitArray to integer in PowerShell
Summary
I'm trying to convert a 32-bit BitArray into an integer using PowerShell version 7. I've tried the C# way of handling it, but it doesn't work.
Here's my code.
$high = [System.Collections....
0
votes
1
answer
165
views
Initializing a bitarray object in assembly
As a (beginner) exercise, I am trying my hand at implementing something like a class in assembly. For this, I would like to create a BitArray of size N and have the operations of init(size), set(idx),...
0
votes
1
answer
614
views
Bit array Vs Bit vector
I am trying to figure out the difference between a bit array and a bit vector.
When browsing the web I find conflicting information.
Some sources claim that a bit array is simply an array with 1s and ...
0
votes
2
answers
522
views
BitArray.And method in VB.Net
I am learning VB.Net and facing an unexpected result from the following codes - running this in Visual Studio:
There are 4 BitArrays: bit1, bit2, bit3 and bit4
bit1 has value 60
bit2 has value 13
bit3 ...
1
vote
1
answer
127
views
Determining if a bit array is in a collection of bit arrays
Given 2-dimensional NxN bit arrays, I'm trying to evaluate the best way to determine if a bit array is already in a large collection of previously seen bit arrays.
A straightforward approach would put ...
3
votes
4
answers
2k
views
How to create a bit array in common lisp?
After googling for about an hour, I have to confess, that while I find a lot of documentation about functions operating on bit arrays, I cannot find a single reference on how to actually create a bit ...
0
votes
0
answers
25
views
How to extract set of bits from BitArray in C#? [duplicate]
For eg.
uint Data= 0x91ADC800;
BitArray myBitArray = new BitArray(BitConverter.GetBytes(Data));
BitArray ExtractArray;//This should have data from 20th bit to 31st bit
I tried BitArray.Copyto(..) ...
2
votes
1
answer
660
views
Extract bit from bitarray according to index list in Python?
I have two bitarray objects (N.B. bitarray != BitArray) which look like
a = bitarray('10010110')
b = bitarray('01001110')
I want a new bitarray "c" which contains the elements of a at indexes where ...
2
votes
1
answer
325
views
Equivalent of c# BitArray.CopyTo of java BitSet
I want to translate the following c# code into java code, but i cannot find the equivalent of copyTo of Java BitSet
public byte [] translate(BitArray mask)
{
byte[] tmp = new byte[(mask....
2
votes
0
answers
448
views
Value becomes null when De-serialize with the model after changed to short-hand property in C#
In my solution to serialize data with the model and stored as bit array in SQL and it retrieving the bit array and then Deserialize with the same model. In the model we have done one change. The ...