devxlogo

Handling Extremely Large Integers

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.

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist