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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:38:39+00:00 2026-06-11T16:38:39+00:00

A bitmap sort programme,in which the assign part is: for(i = MAX/64-1;i >= 0;i–){

  • 0

A bitmap sort programme,in which the assign part is:

for(i = MAX/64-1;i >= 0;i--){
    for(j = 0;j < 64;j++){
        if(0 != (arr[i] & (1 << j))){
            *p++ = j + 64 * i;  
        }   
    }   
}

I gdb it,sometimes when the if condition returns 0 and the program still enter the block and execute the statement:
*p++ = j + 64 *i;
which cause segmentfault at last,I just don’t understand under which circumstance would it happen

example:
when gdb status like this:
j=44, i=6250, arr[i]=4096 and print (arr[i] & (1 << j)) gives 0
but programme still enter the block

  • 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-11T16:38:40+00:00Added an answer on June 11, 2026 at 4:38 pm

    My guess is that you have 32 bit ints but your array data type is int64_t. In which case you need to change:

        if(0 != (arr[i] & (1 << j))){
    

    to:

        if(0 != (arr[i] & (1LL << j))){
    

    since 1 << j is undefined for j >= sizeof(int) * CHAR_BIT (i.e. j >= 32 in your case).

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

Sidebar

Related Questions

I have a Bitmap (in C#) which contains a silhouette of a single person
I have a program (time lapse maker) which has two threads that updates a
I have written some code to create dynamic banners. It returns a bitmap variable.
I'm sort of new to rendering graphics with GDI... I made a paint program,
I have an android program which draws lines and text to a canvas. (These
This is sort of a two part question. I'm building a flash image viewer
Bitmap bmp(100,100, PixelFormat32bppARGB); bmp.SetPixel(2,2,Gdiplus::Color::AliceBlue); int x = bmp.GetHeight(); int y = bmp.GetWidth(); Gdiplus::Color* ccc
I have bitmap image variable and i want to bind it to my xaml
I hava a Bitmap variable named bmp in Activity1 , and I want to
Quick question on Bitmap repeat x and y, i tried the following and it

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.