Velocity Reviews > very very very long integer

# very very very long integer

Abhishek Jha
Guest
Posts: n/a

 10-16-2004
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 http://www.velocityreviews.com/forums/(E-Mail Removed)

Karthik Kumar
Guest
Posts: n/a

 10-16-2004
Abhishek Jha wrote:
> 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 Removed)

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

--
Karthik. http://akktech.blogspot.com .
' Remove _nospamplz from my email to mail me. '

jacob navia
Guest
Posts: n/a

 10-16-2004
Karthik Kumar wrote:
> Abhishek Jha wrote:
>
>> 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 Removed)

>
>
> 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.

Karthik Kumar
Guest
Posts: n/a

 10-17-2004
jacob navia wrote:
> Karthik Kumar wrote:
>
>> Abhishek Jha wrote:
>>
>>> 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 Removed)

>>
>>
>>
>> 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.
>
>

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.

--
Karthik. http://akktech.blogspot.com .
' Remove _nospamplz from my email to mail me. '

jacob navia
Guest
Posts: n/a

 10-17-2004
Karthik Kumar wrote:
> jacob navia wrote:
>
>> Karthik Kumar wrote:
>>

> 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.