very very very long integer

A

Abhishek Jha

You can implement very very long integer using strings. Strings have
no limit and using your own code implementation you can store the
numbers of as much length as you want..........for more details
contact at (e-mail address removed)
 
K

Karthik Kumar

Abhishek said:
You can implement very very long integer using strings. Strings have
no limit and using your own code implementation you can store the
numbers of as much length as you want..........for more details
contact at (e-mail address removed)

But how would u perform the arithmetic operations
if you are storing them as strings.
 
J

jacob navia

Karthik said:
But how would u perform the arithmetic operations
if you are storing them as strings.
You can do that without any problems:
"12345"
+
"12345"

Start at the end:
Carry = 0

loop:
('5' - '0') + ('5' - '0') ==> result 10

write Carry + '0' + result%10 to output string.

Carry = result/10,

goto loop;

Some bignums libraries use this representation.
 
K

Karthik Kumar

jacob said:
You can do that without any problems:
"12345"
+
"12345"

Start at the end:
Carry = 0

loop:
('5' - '0') + ('5' - '0') ==> result 10

write Carry + '0' + result%10 to output string.

Carry = result/10,

goto loop;

Some bignums libraries use this representation.
Apparently that seems less efficient in terms of computation
complexity compared to a linked list. The reason is here -
at any given time, we are processing one digit. Whereas when represented
as long, we can process a good number of digits at any given time , more
than 1.
 
J

jacob navia

Karthik said:
Apparently that seems less efficient in terms of computation
complexity compared to a linked list. The reason is here -
at any given time, we are processing one digit. Whereas when represented
as long, we can process a good number of digits at any given time , more
than 1.

Yes. But it is easier to handle than binary, and binary-->decimals
conversions are very cheap... nothing needs to be done.
 

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

Staff online

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top