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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:23:01+00:00 2026-06-14T05:23:01+00:00

I am trying to raise and arbitrarily larger number to an arbitrarily large power.

  • 0

I am trying to raise and arbitrarily larger number to an arbitrarily large power. As far as I can see, GMP has a function that does this, but applies modulo to the result, and a function that lets me raise an arbitrary number to an unsigned int exponent. Is there a way around this?

  • 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-14T05:23:02+00:00Added an answer on June 14, 2026 at 5:23 am

    and a function that lets me raise an arbitrary number to an unsigned int exponent

    It’s an unsigned long int exponent, so if you are on a system where unsigned long is 64 bits (or more), that will take you beyond the available memory for the next few years (2^(2^64-1) needs a couple of Exabytes storage).

    If you’re on a system with 32-bit unsigned long, you can split the exponent in two parts,

    if (exponent >= (1u << 31)) {
        mpz_pow_ui(base, base, exponent >> 31);
        mpz_pow_ui(base, base, 1u << 31);
    }
    mpz_pow_ui(base, base, exponent & ((1u << 31) - 1));
    

    and that has very good chances of needing more memory than you have.

    A further problem is that GMP uses ints to count the limbs, so typically you can’t have numbers using more than (2^31 - 1)*BITS_PER_LIMB bits anyway (BITS_PER_LIMB is 32 or 64 depending on the platform, usually).

    If you think you need a^b where a > 1 and b doesn’t fit in an unsigned long (long), you will have problems with GMP and your memory anyway.

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

Sidebar

Related Questions

I'm trying to write a unit test that will raise an event on a
I'm trying to create a stored proc that indicates a pay raise for two
I am trying to raise an event to all of the widgets that catch
I'm trying to raise a PropertyChanged event that is being listened to by a
I'm trying to create an application event (java) that would raise as soon as
i am trying to create a support system. In which user can raise ticket
I am trying to implement infer_class function that, given a method, figures out the
I'm trying to serialize some data to xml in a way that can be
I'm trying to raise an event in a mocked interface. I can get this
I'm trying to implement a file watcher that will raise an event if 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.