bit-packing Questions

9

Solved

I have 8 bool variables, and I want to "merge" them into a byte. Is there an easy/preferred method to do this? How about the other way around, decoding a byte into 8 separate boolean values? I c...
Rotl asked 11/12, 2011 at 0:53

4

Solved

I want to encode/compress some binary image data as a sequence if bits. (This sequence will, in general, have a length that does not fit neatly in a whole number of standard integer types.) How ca...
Cynthy asked 21/2, 2011 at 12:45

2

Solved

A struct with bitfields, even when "packed", seems to treat a bitfield's size (and alignment, too?) based on the specified int type. Could someone point to a C++ rule that defines that be...

7

Solved

Low level bit manipulation has never been my strong point. I will appreciate some help in understanding the following use case of bitwise operators.Consider... int age, gender, height, packed_info...
Charybdis asked 2/7, 2011 at 12:24

3

Solved

Update: This is called a de Brujin torus, but I still need to figure out a simple algoritm in C#. http://en.wikipedia.org/wiki/De_Bruijn_torus http://datagenetics.com/blog/october22013/index.html...
Devilfish asked 11/6, 2015 at 10:45

7

I have an array of integers, lets assume they are of type int64_t. Now, I know that only every first n bits of every integer are meaningful (that is, I know that they are limited by some bounds). ...
Telencephalon asked 7/3, 2010 at 19:44

9

Solved

During a code review I've come across some code that defines a simple structure as follows: class foo { unsigned char a; unsigned char b; unsigned char c; } Elsewhere, an array of these objec...
Priory asked 4/11, 2009 at 20:24

2

Solved

I'm experimenting with optimizing parser combinators in C#. One possible optimization, when the serialized format matches the in-memory format, is to just do an (unsafe) memcpy of the data to be pa...
Camden asked 7/7, 2013 at 7:13

3

Solved

I wish to move bits 0,8,16,24 of a 32-bit value to bits 0,1,2,3 respectively. All other bits in the input and output will be zero. Obviously I can do that like this: c = c>>21 + c>>14...
Substantive asked 10/1, 2012 at 11:56

1

Solved

I'm making a class PackedUnsigned1616 which stores two unsigned shorts in one int, and a class PackedSigned1616 which stores two signed shorts in one int. I've read up on bitwise operations, but I'...
Lycanthrope asked 8/5, 2011 at 20:29

5

Solved

To clarify my question, let's start off with an example program: #include <stdio.h> #pragma pack(push,1) struct cc { unsigned int a : 3; unsigned int b : 16; unsigned int c : 1; unsign...
Acid asked 12/10, 2010 at 21:31

1

Solved

Is there a library for C# that allows similar functionality to python's struct from the standard library? One can emulate the struct library quite closely with real aligned structs. But I didn't f...
Evslin asked 30/11, 2009 at 7:1
1

© 2022 - 2024 — McMap. All rights reserved.