# Questions tagged [bitwise]

Bitwise refers to a bitwise operation which operates on one or more bit patterns or binary numerals at the level of their individual bits.

270 questions
Filter by
Sorted by
Tagged with
153 views

### Multiplying many times

I needed to find away to left shift a number on a platform with buggy << and >> bitwise operators. I came up with a ...
10k 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 ...
178 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): ...
775 views

### Finding patterns in a growing collection

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 ...
2k views

### Managing a bit array

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. ...
11k 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? ...
1k views

### Algorithm with byte shifts and BCD calculation

I'm trying to develop an algorithm that generates a 16-digit validation number to interact with a given system. This is how the algorithm should be implemented: I have implemented it, and have it ...
767 views

### Jon Bentley's bitmap sort implementation

I've implemented Jon Bentley's bitmap sorting algorithm from Column 1 of his Programming Pearls book. This code supports user-defined integer range (works from ...
2k views

### Bit rotations exercise

I'm studying C on K&R and I solved exercise 2.08: Write a function rightrot(x,n) that returns the value of the integer x ...
15k views

### Bitmap implementation

I recently started cleaning up my projects and decided that I want to create a personal repository of useful bits of code. I found this bitmap code between them and heavily edited it and I'd ...
36k views

### Fastest way to clamp an integer to the range 0-255

I'm working on some image processing code that can generate pixel values outside of the normal range of 0 to 255, and I'd like to clamp them back into the valid range. I know that there are saturating ...
326 views

### Print Bits Part III

The last question I have been playing around with is a right rotate. I think it is also called a barrel roll. Please post if you have a better solution please post. I am still learning the art of bit ...
940 views

### Print Bits Part II

Could you suggest ways of making this more simple? ...
11k views

### Copying 80 bytes as fast as possible

I am running a math-oriented computation that spends a significant amount of its time doing memcpy, always copying 80 bytes from one location to the next, an array ...
64k views

### Pack and unpack bytes to strings

I need to write a function that "packs" an array of bytes (integers between 0 and 255) into a string. I also need to be able to perform the reverse operation, to get my byte array from the string that ...
2k views

### Custom integer class for calculating crypto algorithms

How can I improve upon this integer class that I wrote? I am/will be using this for some calculation intensive crypto algorithms, mainly POLY1305AES. I might even write RSA using this. I know that ...
10k views

### Decoding binary coded decimal (BCD) value

I have 3 questions, all of them are concerned with binary coded decimal (BCD) conversion. My coding snippets are listed as follows. But I don't like my algorithm because it takes too long when dealing ...