#unsigned char array[32] >> 5

6 messages · Page 1 of 1 (latest)

daring viperBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

sacred perch
#

How can I shift all bits of an array?

clear pond
#
void fives (unsigned char *eight, unsigned char *five, int n) {
  int bits = 0;
  int value = 0;
  do {
    if (n == 0) return;
    if (bits < 5) value |= (*eight++) << bits, bits += 8, n--;
    *five++ = value & 31;
    value >>= 5;
    bits -= 5;
  } while (1);
}
sacred perch
#

I wanted to create my own base32 converter @clear pond

#

[It does not need to be accurate for the last 1-4 bits]