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 7188211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:01:25+00:00 2026-05-28T19:01:25+00:00

I am uncompressing some data from double words. unsigned char * current_word = [address

  • 0

I am uncompressing some data from double words.

unsigned char * current_word = [address of most significant byte]

My first 14 MSB are an int value. I plan to extract them using a bitwise AND with 0xFFFC.

int value = (int)( (uint_16)current_word & 0xFFFC );

My next 6 bits are a fractional value. Here I am stuck on an efficient implementation. I could extract one bit at a time, and build the fraction 1/2*bit + 1/4+bit + 1/8*bit etc … but that’s not efficient.

float fractional = ?

The last 12 LSB are another int value, which I feel I can pull out using bitwise AND again.

int other_value = (int) ( (uint_16)current_word[2] & 0x0FFF );    

This operation will be done on 16348 double words and needs to be finished within 0.05 ms to run at least 20Hz.

I am very new to bit operations, but I’m excited to learn. Reading material and/or examples would be greatly appreciated!

Edit: I wrote OR when I meant AND

  • 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-05-28T19:01:27+00:00Added an answer on May 28, 2026 at 7:01 pm

    Since you’re starting with [address of most significant byte] and using increasing addresses from there, your data is apparently in Big-Endian byte order. Casting pointers will therefore fail on nearly all desktop machines, which use Little-Endian byte order.

    The following code will work, regardless of native byte order:

    int value = (current_word[0] << 6) | (current_word[1] >> 2);
    double fractional = (current_word[1] & 0x03) / 4.0 + (current_word[2] & 0xF0) / 1024.0;
    int other_value = (current_word[2] & 0x0F) << 8 | current_word[3];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some python code that: Takes a BLOB from a database which is
Is it possible to list the contents of a LZMA file (.7zip) without uncompressing
I just saw the first Git tutorial at http://blip.tv/play/Aeu2CAI . How does Git store
I have some .gz compressed files which is around 5-7gig uncompressed. These are flatfiles.
In a long run command line execution, like uncompressing a large .zip archive, how
I wonder if anyone can shed some light on an issue that is driving
The thing is like this. I have a zip file with images that uncompressing
Suppose I've got some Arch Linux installation which I'd like to distribute among students
I'm using java.util.zip to compress and uncompress byte arrays, using Inflater and Deflater .
I am sending large datasets in JSON format from my server (using PHP). I

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.