Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: C++
Expertise: Beginner
Aug 12, 1999

Handling Extremely Large Integers

Question:
I'm trying to write an app that handles some complex mathematical functions, but am hitting a wall in regards to the int data type. I need to store and manipulate a few extremely large (2,048 bit) numbers.

Is there any way to define my own data type and allocate the memory by myself? (I'm using Borland's C++Builder 4 on a Win32 system.)

Answer:
The way I would handle this is to create a class and store the data internally as an array. You could overload various operators (+, –, ==, etc.) and class objects would behave pretty much like any other integer value. But it would be up to you to implement adding, subtracting, etc., so that lower bits correctly overflowed to higher bits.

Personally, I think it might be easier to implement this in assembly language but that would require a bit of thought either way.

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date