Questions tagged [bit-packing]

Use this tag for questions related to bit packing, for example packing bits into integer types.

is used in its general concept, and is usually found in questions using C (or C based languages) or Java.

64 questions
0
votes
2 answers

Packing a 40 byte SHA in 20 bytes in Clojure

To pack a 40 byte SHA in 20 bytes, we are doing this: (defn pack-sha-1 [sha-1] (->> sha-1 (partition 2) (map (partial apply str)) ;; To convert back to list of strings (map (fn [hex] (-> hex …
Suvrat Apte
  • 161
  • 10
0
votes
0 answers

Are there bit (un)packing instructions in common x86_64 processor line mmx command for bytes?

dead hachers! Background: Maybe you know mmx packing/unpacking instruction set, what howewer works on bytes and larger volumes, like shorts, words, etc. Quesion: Are there any instructions for any x86_64 processor, to do the similar…
0
votes
1 answer

How to optimally compress inverted indexes for time series dataset

I am attempting to compress a time series dataset with a compress ratio of 25%. This has turned into a vendetta for me. The data is of 1-minute interval historical stock quotes over a 1 month period ( see notes for dataset ) with 0 missing data.…
darthS
  • 31
  • 4
0
votes
0 answers

Compress string using bit field

I have to encode an array of strings such that: 1. The encoded output is a single string with minimum possible length 2. You should be able to decode the string later. String is made up of only lower case characters. I am not very good in using bit…
user968000
  • 1,765
  • 3
  • 22
  • 31
0
votes
0 answers

How to encode struct into binary with bit packing in Golang

I am trying to encode large data structs into binary. I have specified number of bits for each struct element. So I need to encode struct into binary according to bit length. Standard Golang library Encoding/binary packs each item minimum as one…
user38138
  • 11
  • 3
0
votes
3 answers

Bit fields maked more optimized

I'm making some code for a 16 bits microprocessor. My memory is quite limited at 128 KB. IAR C/C++ Compiler for MSP430 I need to implement some code to save some memory. I tried to implemented this with this C characteristic implementation. struct…
MrSpartan
  • 37
  • 5
0
votes
0 answers

Properly bit packing for enum and typedef struct

I am trying to do some bit packing to transmit data in the small format possible, but I am unsure how to archive it, I started with a typedef struct where I gave the size to each element, but when I am trying to transmit it using UART, in the other…
Kirito-kun
  • 31
  • 1
  • 5
0
votes
1 answer

Packing multiple integers into a 64 bit integer

I want to pack the following numbers into a 64 bit int64_t field in the following order: int8_t num1 int8_t num2 int32_t num3 int16_t num4 So, the 64 bits should be in the following layout: [ num1(8) | num2(8) | num3(32) | …
jeffreyveon
  • 13,400
  • 18
  • 79
  • 129
0
votes
1 answer

GLSL - compressing/packing multiple 0-1 colours (var4) into a single var4 variable

I am trying to do the following in GLSL 2 es: Given a number (say 4 for example) of normalized var4 variables(RGBA) reduce their bit depth and pack the results in a single 0-1 clamped var4. This will be stored as an 8 bit (per channel) texture and…
Child
  • 3
  • 3
0
votes
3 answers

Struct Bit Packing and LSB / MSB ambiguity C++

I had to write a c++ code for the following packet header: Original image link, PNG version of the above JPEG. Here is the struct code I wrote for the above Packet Format. I want to know if the uint8_t or the uint16_t bit fields are correct …
rkrishnasanka
  • 166
  • 1
  • 9
0
votes
1 answer

Pack multiple values into single data type

I'm interested in making a class to store data in a more pact manor and I know I can store numbers between 0 and 2^(x)-1 with ease, along with booleans by using bitwise operators, but I'm interested in more odd numbers like a max of 6 or…
vzybilly
  • 323
  • 3
  • 14
0
votes
5 answers

Packing chars into 5 bits and writing results to file (C++)

I have a vector containing chars. These chars can only be the 26 upper-case letters of the alphabet, hence the number of bits representing these characters can be reduced from 8 to 5. I then need to write the results into a file, to be used…
Craig
  • 145
  • 1
  • 1
  • 7
0
votes
2 answers

Specifying bit size of array elements in a struct

Now I have a struct looking like this: struct Struct { uint8_t val1 : 2; uint8_t val2 : 2; uint8_t val3 : 2; uint8_t val4 : 2; } __attribute__((packed)); Is there a way to make all the vals a single array? The point is not space…
aplavin
  • 2,199
  • 5
  • 32
  • 53
0
votes
3 answers

Python mangles struct.pack strings written to disk

I'm working on an application writing binary data (ints, doubles, raw bytes) to a file. Problem is, that the data is not actually written to the file the way I expect it to be: >>> import struct >>> import io >>> out = io.open("123.bin", "wb+") >>>…
Hubert Kario
  • 21,314
  • 3
  • 24
  • 44
0
votes
1 answer

Client-Server Data Encryption and Protocol Design

I'm writing a client-server application to be used in a computer lab and act as a service (without running as a service). I have a console application calling the native function "ShowWindow"/SW_HIDE using the console's HWND object -- this gives it…
Zack
  • 2,477
  • 4
  • 37
  • 50