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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:00:46+00:00 2026-06-13T19:00:46+00:00

I am trying to solve a problem using bit operations in C++ but i

  • 0

I am trying to solve a problem using bit operations in C++ but i am really stuck. Please help me with the following query.

1) Is it possible to create variable’s A and B which take exactly 100000bits in memory and on which an operation like A&B is valid?

2) Is there a fast way to generate B(100000bits) such that its first n bits are 0, last m bits are 0 and the remaining are 1’s? (eg. if B was 10bits then a number like 0000011000)

  • 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-13T19:00:48+00:00Added an answer on June 13, 2026 at 7:00 pm

    In answer to 1, sure, this is the sort of things classes were meant for. Simply create a class containing 100,000 bits (about 12.5K) and override the operator& method (the binary one, not the address-of operator).

    A good start would be (say we have two integers holding the bitmask):

    BigBits BigBits::operator &(const BigBits &that) const {
        BigBits bb(*this);
        bb.array[0] = this->array[0] & that.array[0];
        bb.array[1] = this->array[1] & that.array[1];
        return bb;
    }
    

    This is untested but should give you the basic idea. In order to test it, I’d have to code up quite a bit, including constructors, destructors, assignments and so forth, when that really should be your task 🙂

    In answer to two, that’s also easy. The only trick bits are the two edge bytes, all the internal bytes can just be set to all 1 bits.

    In order to set the edge bytes, you use a bit of division and modulo with the number of bits in a byte and then use bitmasks to set them. The bitmasks would be 0x80, 0xc0, 0xe0, 0xf0, 0xf8 and so on, with each subsequent value adding another 1 bit.

    Then you would use bitmask[bitpos % 8] in its various forms to set the edge bytes, the array indexes of which would be bitpos / 8.

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

Sidebar

Related Questions

I am trying to solve Project Euler problem in Clojure using recursion. The following
Using six-bit one's and two's complement representation I am trying to solve the following
I'm trying to solve this problem in a pure-functional way, without using set! .
I'm trying to solve the problem here but I don't know why my code
I'm trying to solve this particular problem using c++. Problem: Given a set of
I am trying to solve a problem /implementation using xpath. Using code (python) is
I'm trying to solve Problem 13 of project euler, which involves the sum of
Trying to solve a problem with templatetags. I have two templatetags: @register.inclusion_tag('directory/_alphabet.html') def alphabet_list(names):
Trying to solve this problem . I would like to learn how the bootstrapper
I am trying to solve this problem http://www.spoj.pl/problems/PEBBMOV/ . I think I have the

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.