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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:49:29+00:00 2026-06-01T07:49:29+00:00

I am a newbie for solving these kind of problems. I need to extract

  • 0

I am a newbie for solving these kind of problems. I need to extract variable no of bits from a single short value.

Like If I have read something from an array and need to fill another array first reading the 10 bits from earlier read value , and then again 6 bits to another short.

Like:

 int pixelNo = 0;
 short pixelValue_part = pixels[pixelNo]; 
 // but here i need only 10 bits , in the second 
 // iteration i might need 4 bits and then so on so forth.

After reading these shorts in parts, I will have to put these parts into
second array sequentially inorder to arrange all pixels in the sequence.

Note :

The problem is of arranging all input pixel sequence in ascending ordered way.I have to arrange the pixels of each having size of 10 bits. For this reason I would need read first 10 bits of short.

Edit:


| | 0,1 512,513 1024,1025 1536,1537 1,2,3 513,514,515 1025,1206,1027 1357,1538,1539
|_|____|___|___|_|___|______|______

I have above array as input and I want to produce output like the following array.


| | 0,1 2,3 4,5 6,7 …… 513,514,515,1024,1025,1536,1537…
|_|____|___|___|_|___|______|______

Values of arrays all are Pixels of some image. So in actual the image was unarranged in pixels in input array, and then the second array is the array of arranged (sorted ) pixels.

  • 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-01T07:49:30+00:00Added an answer on June 1, 2026 at 7:49 am

    Assuming your original data is in src, and you want a span of n bits (starting n+pos bits from the low end), this will extract those bits:

    (src >> pos) & ((1<<n)-1)
    

    Breaking it down:

    • (1<<n)-1 is a mask of n 1’s (binary)
    • src >> pos slides the bits you want down to the “bottom” of the variable
    • Then we bitwise-and the two together, effectively erasing the bits you don’t want, leaving behind the ones you do

    You can do this for each piece you need. To put the pieces together, you’d use << to shift pieces where you need them to be and then | (bitwise-or) the pieces together.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Newbie question. I have Django models that look like this: class Video(models.Model): uploaded_by =
I am working on a solution that aims at solving problems that newbie programmers
Newbie question. I want to do something like: SELECT c1,c2,c3 FROM TABLE t1 UNION
Newbie in PHP. I'm getting a value of an array index in my variable
I'm newbie in PHP. I have to code the system like RSS Reader in
newbie rails question coming up. I have a class like this: class Thing <
newbie here, so thanks in advance for help! I have a Wordpress site with
Newbie question... The objective: I intend to have an HTML text input field as
newbie for clearcase. Since clearcase's config is rather different from other concept in git,
I'm currently solving a programming problem to enhance my skills (I'm still a newbie)

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.