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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:30:20+00:00 2026-05-25T18:30:20+00:00

My question is how do I compute 2^(x) in c. I know there is

  • 0

My question is how do I compute 2^(x) in c. I know there is something like shifting that does the same thing. I tried to do total = x << 1, but that didn’t work. I know that if i shift one bit it is the same as multiplying it by two. Or something like that.

int x;

for(x=0; x<4; x++){

total += x <<1; // 

}

When this is done executing I expect the total to be 15 ( 20 + 21 + 22 + 23 )

Any ideas on what I am doing wrong? my total starts off as being 0 and then messes up.

Thanks!

  • 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-25T18:30:21+00:00Added an answer on May 25, 2026 at 6:30 pm

    It’s the other way around. 1 << x will give you ‘2 ^ x’.

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

Sidebar

Related Questions

my question is kinda simple but i just don't know how to get it.
Here is the question: There are 5 sorted list A,B,C,D,E, which has the same
I know this question has been asked before, but none of the existing SO
OK, this is more of a follow-up question: How to compute optimal paths for
This question asks how to compute the Cartesian product of a given number of
Arising out of this question, I'm looking for an elegant (ruby) way to compute
I'm working on my first professional project. The fact is that I don't know
This may be waaay to specific for SO, but there seems to be a
I know that you can easily send a ping request and receive a boolean
My website has a search procedure that runs very slowly. One thing that slows

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.