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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:26:44+00:00 2026-06-10T21:26:44+00:00

How to find 2^x quickly in C. If you guys have any idea please

  • 0

How to find 2^x quickly in C. If you guys have any idea please help.

  • 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-10T21:26:46+00:00Added an answer on June 10, 2026 at 9:26 pm

    Bitshift to the left, this multiplies numbers by 2 for every place shift, in the same way that shifting decimal numbers to the left multiplies them by 10.

    Use the << operator, like so:

    int twoPowZero = 1; // any number^0 is 1
    int twoPowOne  = 1 << 1; // this sets the '2' bit to '1'
    int twoPowTwo  = 1 << 2;
    int twoPowFive = 1 << 5;
    int twoPowTen  = 1 << 10;
    

    and so on until you get to 1 << 30. If you’re using a signed 32-bit integer then 1 << 31 will give you -2147483648 because of two’s complement. If you want to go higher than use long long unsigned int or uint64_t (64-bit integer). Or if your platform supports it: uint128_t.

    If you want to go even higher, you’ll need to roll your own “big integer” code. Note that some platforms and compilers come with a 128-bit integer type, but runtime performance varies: they may require a processor that can perform 128-bit operations, or they might break it down into two 64-bit operations.

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

Sidebar

Related Questions

I want to quickly find the total size of any folder using python. import
Ok guys, just a quick question hopefully someone can find my mistake quickly, but
How can I quickly find, given a folder with .Net assemblies, which of these
using bsearch() in C (standard library) one can quickly find an entry in a
find whether there is a loop in a linked list. Do you have other
find . -type f -print prints out ./file1 ./file2 ./file3 Any way to make
In order to find quickly the location of my data, I display a table
The SQL index allows to find quickly a string which matches my query. Now,
I need to be able to quickly find n closest destinations for a given
I would like to know how to quickly find the specific function called by

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.