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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:41:08+00:00 2026-05-26T13:41:08+00:00

First off, I’m doing this for myself so please don’t suggest use GMP /

  • 0

First off, I’m doing this for myself so please don’t suggest “use GMP / xint / bignum” (if it even applies).

I’m looking for a way to convert large integers (say, OVER 9000 digits) into a int32 array of 232 representations. The numbers will start out as base 10 strings.

For example, if I wanted to convert string a = "4294967300" (in base 10), which is just over INT_MAX, to the new base 232 array, it would be int32_t b[] = {1,5}. If int32_t b[] = {3,2485738}, the base 10 number would be 3 * 2^32 + 2485738. Obviously the numbers I’ll be working with are beyond the range of even int64 so I can’t exactly turn the string into an integer and mod my way to success.

I have a function that does subtraction in base 10. Right now I’m thinking I’ll just do subtraction(char* number, "2^32") and count how many times before I get a negative number, but that will probably take a long time for larger numbers.

Can someone suggest a different method of conversion? Thanks.

EDIT
Sorry in case you didn’t see the tag, I’m working in C++

  • 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-26T13:41:09+00:00Added an answer on May 26, 2026 at 1:41 pm

    Assuming your bignum class already has multiplication and addition, it’s fairly simple:

     bignum str_to_big(char* str) {
         bignum result(0);
         while (*str) {
             result *= 10;
             result += (*str - '0');
             str = str + 1;
         }
         return result;
     }
    

    Converting the other way is the same concept, but requires division and modulo

    std::string big_to_str(bignum num) {
        std::string result;
        do {
            result.push_back(num%10);
            num /= 10;
        } while(num > 0);
        std::reverse(result.begin(), result.end());
        return result;
    }
    

    Both of these are for unsigned only.

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

Sidebar

Related Questions

First off, I know this may be a very stupid question, so don't shoot
First off, there's a bit of background to this issue available on my blog:
First off, this question is ripped out from this question. I did it because
First off, I apologize if this doesn't make sense. I'm new to XHTML, CSS
First off, fairly new to JS but getting better :-) This question is similar
First off, I'll admit I'm cargo-culting this a little bit -- my nice clean
First off, I would like to state this is on a practice exam I
first off I am a rookie so please forgive my basic question. I am
First off, please forgive me for my lack of understanding... I'm still learning :)
First off, apologies if this question has been asked before but I couldn't find

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.