Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8066295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:56:21+00:00 2026-06-05T11:56:21+00:00

I have a buffer of bits with 8 bits of data followed by 1

  • 0

I have a buffer of bits with 8 bits of data followed by 1 parity bit. This pattern repeats itself. The buffer is currently stored as an array of octets.

Example (p are parity bits):

0001 0001 p000 0100 0p00 0001 00p01 1100 …

should become

0001 0001 0000 1000 0000 0100 0111 00 …

Basically, I need to strip of every ninth bit to just obtain the data bits. How can I achieve this?

This is related to another question asked here sometime back.

This is on a 32 bit machine so the solution to the related question may not be applicable. The maximum possible number of bits is 45 i.e. 5 data octets

This is what I have tried so far. I have created a “boolean” array and added the bits into the array based on the the bitset of the octet. I then look at every ninth index of the array and through it away. Then move the remaining array down one index. Then I’ve got only the data bits left. I was thinking there may be better ways of doing this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T11:56:22+00:00Added an answer on June 5, 2026 at 11:56 am

    Your idea of having an array of bits is good. Just implement the array of bits by a 32-bit number (buffer).

    To remove a bit from the middle of the buffer:

    void remove_bit(uint32_t* buffer, int* occupancy, int pos)
    {
        assert(*occupancy > 0);
        uint32_t high_half = *buffer >> pos >> 1;
        uint32_t low_half = *buffer << (32 - pos) >> (32 - pos);
        *buffer = high_half | low_half;
        --*occupancy;
    }
    

    To add a byte to the buffer:

    void add_byte(uint32_t* buffer, int* occupancy, uint8_t byte)
    {
        assert(*occupancy <= 24);
        *buffer = (*buffer << 8) | byte;
        *occupancy += 8;
    }
    

    To remove a byte from the buffer:

    uint8_t remove_byte(uint32_t* buffer, int* occupancy)
    {
        uint8_t result = *buffer >> (*occupancy - 8);
        assert(*occupancy >= 8);
        *occupancy -= 8;
        return result;
    }
    

    You will have to arrange the calls so that the buffer never overflows. For example:

    buffer = 0;
    occupancy = 0;
    add_byte(buffer, occupancy, *input++);
    add_byte(buffer, occupancy, *input++);
    remove_bit(buffer, occupancy, 7);
    *output++ = remove_byte(buffer, occupancy);
    add_byte(buffer, occupancy, *input++);
    remove_bit(buffer, occupancy, 6);
    *output++ = remove_byte(buffer, occupancy);
    ... (there are only 6 input bytes, so this should be easy)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So.. I have a buffer with MP3 data (If I would save this buffer
I have this loop which splits a Boolean LinkedList by 8 bits and return
I have a memory buffer corresponding to my screen resolution (1280x800 at 24-bits-per-pixel) that
Can anyone help converting the Int to char array as i have buffer as
I have buffer/payload of integers where every 4 bytes is a field which i
I have a buffer in class 'bufferClass' that will generate a signal to tell
I have frame buffer, with depth component and 4 color attachments with 4 textures
fclose() is causing a segfault. I have : char buffer[L_tmpnam]; char *pipeName = tmpnam(buffer);
I have a large buffer: char *buf = malloc(1000000000); // 1GB If I forked
I have one big buffer image. I want to create another buffer image with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.