Bitwise refers to a bitwise operation which operates on one or more bit patterns or binary numerals at the level of their individual bits.
2
votes
5answers
219 views
Performance: Divide group of numbers into two groups of which the sums are equal
I have a piece of code that divides a group of numbers into two groups of numbers of which the sums are equal.
I created this because of a StackOverflow question: ...
1
vote
0answers
53 views
JavaScript xor function
I made simple JavaScript xor function. It accepts string, numeric array and mixed array (char, string, num) as params. It returns string or an array.
Returning an array is a must!. All numbers are ...
2
votes
1answer
62 views
Simplify bit flags checking code
Please help make this code more cleaner. It's a part of window procedure that notifies my renderer before client area of window resized.
I need to check two combinations of bit blags: some of them ...
2
votes
0answers
23 views
Fast popcount on Intel Xeon Phi
I'm implementing an ultra fast popcount on Intel Xeon® Phi®, as it's a performance hotspot of various bioinformatics software.
I've implemented five pieces of codes,
#if defined(__MIC__)
#include ...
0
votes
0answers
61 views
Bit array not working as fast as expected [closed]
I recently downloaded the bitarray module from here, for a faster prime sieve, but the results are dismal.
from bitarray import bitarray
from numpy import ones
from timeit import timeit
def ...
4
votes
1answer
93 views
Bitwise Flag code for Python
I am looking for feedback on this compact Python API for defining bitwise flags and setting/manipulating them.
Under the hood, FlagType extends int and all operations are true bitwise, so there is ...
-1
votes
1answer
33 views
What are these bitwise operations doing? [closed]
I found a snippet of code on the PHP manual which packs 64 bit integers. APparently this is necessary because pack() always treats numbers as 32 bit integers even on 64 bit architectures.
I don't ...
1
vote
2answers
209 views
Spotify's “Reversed Binary Numbers” Problem
I wrote some Java code for Spotify's Reversed Binary Numbers puzzle and I tested it on my machine and I am almost positive that it behaves as expected. However, when I send it to puzzle AT spotify.com ...
2
votes
3answers
983 views
Base-36 encoding of a byte array
After posting a question about Alphanumeric Hash generation on StackOverflow, the most helpful answer was to change the conversion method from pulling 5-bit chunks of a binary hash value, to instead ...
1
vote
1answer
99 views
What specific optimizations can be made to this BitArray class, and how can they be implemented?
Here is the current code for the BitArray class needing optimization (implemented on big integers):
import itertools
################################################################################
...
3
votes
1answer
327 views
speeding up an algorithm that find patterns in a growing collection
I want to find a way to speed up this code.
if you look at the condition of If calculated Then in the code below, this is what slowing down the code.
While the code provided seem fast with Const ...
4
votes
3answers
312 views
How to manage a bit array with C programming langage?
I'm training a bit with C, and I'm trying to build a bit array. I would like to have some comments about my code, because I'm not sure that it's the best way to do it.
// BAL.c
#include ...
3
votes
4answers
288 views
Counting the number of bits of a positive integer
How can I improve this code for counting the number of bits of a positive integer n in Python?
def bitcount(n):
a = 1
while 1<<a <= n:
a <<= 1
s = 0
while ...
3
votes
2answers
271 views
bit rotation code review
I'm studing C on K&R and I solved exercise 2.08 ("Write a function rightrot(x,n) that returns the value of the integer x rotated to the right by n positions") with the code below.
I've tested my ...
3
votes
1answer
196 views
Print Bits Part II|: Coding Feedback Wanted
The last question I have been playing around with is a right rotate. I think it is also called a barrel roll. Anyways if you have a better solution please post. I am still learning the art of bit ...
6
votes
3answers
91 views
Print Bits Part II: Coding Feedback Wanted
Does anyone have a shorter more simple way of doing this?
/*
* Next write a function invert(x,p,n) that returns x with the n bits
* that begin at position p inverted, leaving the others unchange
...