Big variable

F

farshad

Hello

for a mathematical program I need to define a variable which can store
a number with about 1,000,000 digits.

the only operation I need is the remainder of division.

I have no idea how to that. I can use any compiler you suggest.

Regards,
 
G

Guest

for a mathematical program I need to define a variable which can store
a number with about 1,000,000 digits.

1,000,000??? !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

You must create a new integer format!
This is not too hard.
An array of char with namy many bytes is my suggestion
the only operation I need is the remainder of division.

try an Eykleidian Division with same way as processors (you must learn basic
digital electronics!) with <<, >>, |, &, ~, ^

ITS TOOOOO SLOOOOW!!!

for floating point number problem is bigger
I have no idea how to that. I can use any compiler you suggest.

A compiler which support numbers with 1,000,000 digits?!
Only one?!!
 
V

Victor Bazarov

farshad said:
for a mathematical program I need to define a variable which can store
a number with about 1,000,000 digits.

the only operation I need is the remainder of division.

I have no idea how to that. I can use any compiler you suggest.

Search the web for "arbitrary precision integer".

Victor
 
J

jbruno4000

Hello
for a mathematical program I need to define a variable which can store
a number with about 1,000,000 digits.

the only operation I need is the remainder of division.

I have no idea how to that. I can use any compiler you suggest.

Regards,

int x = 100000000;
int b;

to devide:

b = x/17
cout << b << endl;
outputs: 5882352

However, '%' returns the remainder':

b = x%17
cout << b << endl;
outputs: 16
 
J

jbruno4000

Hello
for a mathematical program I need to define a variable which can store
a number with about 1,000,000 digits.

the only operation I need is the remainder of division.

I have no idea how to that. I can use any compiler you suggest.

Regards,
I forgot to say, if you're interested in the knowing the largest integer value
your computer can handle, output the value 'MAXINT':

#include <iostream>
#include <values> // for MAXINT

int main()
{
cout << MAXINT;
return 0;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,148
Messages
2,570,838
Members
47,385
Latest member
Joneswilliam01

Latest Threads

Top