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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:50:02+00:00 2026-05-23T07:50:02+00:00

How does a computer know that (int x, y) x << y means shift

  • 0

How does a computer know that (int x, y) x << y means shift over y bits? I don’t mean the shift part. I mean the y part. Does the computer shift x by one and subtract one from y until y == 0? If not how does the computer figures out the value of y?

If say y = 10, then the binary representation is 0b1010.
The computer can’t simply take each bit of 1010 and use it, can it?

I am trying to to this for bit sizes larger than 8. Since the values are not simply stored as arrays of standard integers, the container doesn’t represent a value, so overloading the operators << and >> is a bit harder.
However, counting down from a 100 bit number to 0 is somewhat inefficient, so I’m trying to find a way to make the computer understand a bit array faster.

  • 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-23T07:50:03+00:00Added an answer on May 23, 2026 at 7:50 am

    you’re saying you have 2 bit arrays and you’re trying to create a shift operator for them? the easiest way to do it would probably be to convert the right one, y, into an integer and then shift every bit in x by that amount…..otherwise if you want to operate on it 1 bit at at time it’ll be even less efficient. you’ll look at the first bit, if its 1, shift once, look at the second bit, if its 1, shift twice…i think you have to deal with it as a whole for it to be efficient.


    assuming y can’t fit in an integer…and this is just off the top of my head, but let’s assume an int is only 2 bits, but y is 0b1111. then, take the first 2 bits, convert it to an integer (3) and shift x by that amount. then right-shift y by 2 (the size of our int), and convert that to an int. this makes 3 again, which you’d have to repeat 4 times (int max + 1) for a total of 12. that, + the 3 we did earlier means we’ve shifted x 15 times which was the value of y. you can repeat this process for even larger numbers.

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

Sidebar

Related Questions

Does anyone know of an easy way to copy a database from one computer
How much hardware understanding does one need to fully comprehend Operating System and Computer
I know that if the OpenGL implementation does not find a suitable driver it
What does this line do exactly? (char*) (&input) I know that it converts the
I am reading a programming from the ground up, if you don't know what
Does anyone know of a way to alter a computed column without dropping the
Does someone knows how can I capture my computer screen to a video file?
For some reason, ldap and directory services does not work when the computer is
Regarding the worker pool, what happens when the computer restarts? Does the worker continue
Does Google force employees who have offers from Facebook to leave immediately?

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.