48 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
0
votes
3
answers
266
views
How can I efficiently convert a bigint into a base 2 string and count the 1s?
I have a bigint column or variable. I want to convert it into its bitmap (base 2) representation as a varchar and additionally to that count the 1s.
I need both components - not just the bit_count ...
1
vote
1
answer
81
views
Does ArrayFire have a popcount or bitcount function?
I am trying to move away from OpenCL and CUDA into ArrayFire. One of my functions uses the GPU's popcount() to make pre-processing data easier. But I can't find it anywhere in the list of functions in ...
8
votes
0
answers
280
views
Why newer clang is generating one more instruction than just popcntl to count the bits of an int on haswell architecture?
While watching this talk by Matt Godbolt, I was astonished to see that Clang, if instructed to compile for the Haswell1 architecture, works out that the following code
int foo(int a) {
int count = ...
6
votes
3
answers
5k
views
How can I use the "builtin" function __builtin_ctzll in a VS C++ Project?
I have found out about __builtin_ctzll to count trailing zeros of a 64bit int really fast through the post Intrinsic to count trailing zero bits in 64-bit integers?.
I'm a beginner to C++ and don't ...
0
votes
0
answers
381
views
message output not working due to BitCount and Length being zero
I'm kind of new to CAPL. Today I am trying to use the output function for sending UDS messages on CAN, using a simple code below:
UdsReq.dir = 1;
UdsReq.byte(0) = 0x02;
UdsReq.byte(1)...
0
votes
1
answer
565
views
32 bit builtin population count for clang counts long long integer c++
I was using the __builtin_popcount with clang compiler and I needed to count a 64 bit number (unsigned long long or uint64_t). From looking it up, __builtin_popcount counts 16 bits, ...
-1
votes
2
answers
613
views
How do I make this LC-3 code to count the number of 0s in the value stored in R0 and stores the result into R1
How do I modify this LC-3 code to make it count the number of 0s instead of ones
.ORIG x3000
LD R2, INPUT
AND R0, R0, #0 ; COUNTER INITIALIZED TO ZERO
ADD R1, R0, #1
ADD ...
1
vote
2
answers
262
views
XOR operation and BitCount in Java on Long variables returns java.lang.NumberFormatException
I am trying to do a XOR operation on two 64 bits Long variables in Java.
The problem is that it fails when I add more than 16 bits in a variable.
For instance this works and returns 7:
Long h1 = ...
2
votes
4
answers
1k
views
Matrix transpose and population count
I have a square boolean matrix M of size N, stored by rows and I want to count the number of bits set to 1 for each column.
For instance for n=4:
1101
0101
0001
1001
M stored as { { 1,1,0,1}, {0,1,...
9
votes
2
answers
9k
views
Counting 1 bits (population count) on large data using AVX-512 or AVX-2
I have a long chunk of memory, say, 256 KiB or longer. I want to count the number of 1 bits in this entire chunk, or in other words: Add up the "population count" values for all bytes.
I ...
2
votes
1
answer
633
views
Counting number of '1' values in each bit position in Redshift column
I have BIGINT column in my Redshift table, and I want a query that will:
Count how many times the value '1' appears in each bit position across the binary value in all the rows of this column
Will ...
6
votes
3
answers
3k
views
Java - Big O of bitCount()?
What is the Big O of bit count? I'm not sure how the method works, but I would assume it is done in O(logn).
Specifically with this code (where x = 4, y = 1):
return Integer.bitCount(x^y);
5
votes
3
answers
2k
views
How does Long.bitCount() finds the number of set bits?
I know this is the code. But I'm not able to understand what it does
`public static int bitCount(long i){
i = i - ((i > > > 1) & 0x5555555555555555L);
i = (i & ...
0
votes
0
answers
252
views
Calculate Hamming Distance in SQLite [duplicate]
I wanted to compare multiple images and retrieve the most similar image using hamming distance. The only problem is SQLite which is the most commonly available database in mobile platform doesn't ...
1
vote
2
answers
5k
views
Using an LC3 Simulator to count the number of 1's in a binary number
I am trying to write a program for the LC3 simulator that will allow me to count the amount of 1's in a binary number stored somewhere else in memory. Here is what I have so far:
0011 0001 0000 0000 ...
user avatar
user6638070