Thread: bigint modpow

  1. #1
    Registered User
    Join Date
    Sep 2012
    Posts
    6

    bigint modpow

    hello, im searching a function in c for modular exponentiation modpow using bigint.
    i just find for c#, anyone can help?

  2. #2
    Registered User
    Join Date
    Feb 2019
    Posts
    1,078
    By "bigint" you mean multiple precision arithmetic integer types?
    Try libgmp.

  3. #3
    Registered User
    Join Date
    Sep 2012
    Posts
    6
    i need this function

    Code:
    int power(int x, int exp, int n) 
    { 
        int res = 1;      // Initialize result 
      
        x = x % n;  // Update x if it is more than or  
                    // equal to p 
      
        while (exp > 0) 
        { 
            // If y is odd, multiply x with result 
            if (exp & 1) 
                res = (res*x) % n; 
      
            // y must be even now 
            exp = exp>>1; // y = y/2 
            x = (x*x) % n;   
        } 
        return res; 
    }
    but whit type BIGINT instead int

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    There is no such built-in type named BIGINT. Refer to flp1969's post #2 for a library that can help.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Bigint modification - please help
    By grigorianvlad in forum C++ Programming
    Replies: 7
    Last Post: 09-16-2010, 06:21 AM
  2. BigInt
    By lostandconfused in forum C Programming
    Replies: 16
    Last Post: 09-16-2010, 12:30 AM
  3. HugeInt (BigInt) optimization
    By LuckY in forum C++ Programming
    Replies: 2
    Last Post: 11-16-2004, 11:44 AM
  4. bigInt help
    By noob2c in forum C++ Programming
    Replies: 14
    Last Post: 10-10-2003, 08:18 PM
  5. BigInt- Division
    By BenR in forum C++ Programming
    Replies: 1
    Last Post: 04-10-2003, 04:24 PM

Tags for this Thread