Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > defining large datatypes

Reply
Thread Tools

defining large datatypes

 
 
Nimo
Guest
Posts: n/a
 
      12-29-2010
hi.,

how to deal with numbers which has more than 20 digits..

as I can use a maximum of 'long long'; is there any way to handle
these type of values?

what data type I've to define? and is there any library available to
do these type of calclulations?

Thank You.
so long..
 
Reply With Quote
 
 
 
 
David Resnick
Guest
Posts: n/a
 
      12-29-2010
On Dec 29, 10:06*am, Nimo <(E-Mail Removed)> wrote:
> hi.,
>
> how to deal with numbers which has more than 20 digits..
>
> as I can use a maximum of 'long long'; is there any way to handle
> these type of values?
>
> what data type I've to define? and is there any library available to
> do these type of calclulations?
>
> Thank You.
> * so long..


Google bignum or "arbitrary precision arithmetic", should get you
going. Could start here: http://en.wikipedia.org/wiki/Arbitra...ion_arithmetic.
Yes, need a library. If you don't need precise answers, could use
doubles depending on your application and the range of values needed.

-David
 
Reply With Quote
 
 
 
 
Angus
Guest
Posts: n/a
 
      12-31-2010
On Dec 29, 3:11*pm, David Resnick <(E-Mail Removed)> wrote:
> On Dec 29, 10:06*am, Nimo <(E-Mail Removed)> wrote:
>
> > hi.,

>
> > how to deal with numbers which has more than 20 digits..

>
> > as I can use a maximum of 'long long'; is there any way to handle
> > these type of values?

>
> > what data type I've to define? and is there any library available to
> > do these type of calclulations?

>
> > Thank You.
> > * so long..

>
> Google bignum or "arbitrary precision arithmetic", should get you
> going. *Could start here:http://en.wikipedia.org/wiki/Arbitra...ion_arithmetic.
> Yes, need a library. *If you don't need precise answers, could use
> doubles depending on your application and the range of values needed.
>
> -David


Or you could use a char array. But you would have to handle addition,
subtraction etc. But then you could support an unlimited number
size. The big int libraries will do all this for you in a very
efficient way.

 
Reply With Quote
 
BGB
Guest
Posts: n/a
 
      01-03-2011
On 12/31/2010 6:19 AM, Angus wrote:
> On Dec 29, 3:11 pm, David Resnick<(E-Mail Removed)> wrote:
>> On Dec 29, 10:06 am, Nimo<(E-Mail Removed)> wrote:
>>
>>> hi.,

>>
>>> how to deal with numbers which has more than 20 digits..

>>
>>> as I can use a maximum of 'long long'; is there any way to handle
>>> these type of values?

>>
>>> what data type I've to define? and is there any library available to
>>> do these type of calclulations?

>>
>>> Thank You.
>>> so long..

>>
>> Google bignum or "arbitrary precision arithmetic", should get you
>> going. Could start here:http://en.wikipedia.org/wiki/Arbitra...ion_arithmetic.
>> Yes, need a library. If you don't need precise answers, could use
>> doubles depending on your application and the range of values needed.
>>
>> -David

>
> Or you could use a char array. But you would have to handle addition,
> subtraction etc. But then you could support an unlimited number
> size. The big int libraries will do all this for you in a very
> efficient way.
>


I have some library code to do arithmetic directly using ASCII strings
for input/output.

technically, it supports fairly large numbers (I forget the current max
size, and IIRC was something like 2048.2048 decimal digits or similar,
but it is adjustable anyways...).

more often, smaller fixed-size numbers are more useful though, say,
using a fixed 128 bit number or such...

but, yeah, between using a bignum library or writing it themselves,
either is an option.


supporting variable-sized numbers is more generic, but is a little
harder to do as efficiently, since the logic has to be generic for
whatever input size it is passed (and even then, there needs to be some
practical limit to how big a number can be).

some claim "the number can be as big as there is memory to store it",
but often even such an implementation would be impractical (one needs
temporary memory to store intermediate results, or memory may be
fragmented, or say only 16 bits are used to store the number of machine
words in the result, or...).

and really, what is the liklihood of a person needing
multi-billion-digit numbers anyways?...

"the number may be absurdly huge" or "the number may be up to 629k
digits" or similar is plenty reasonable, without invoking the "numbers
as big as memory" claim.

or such...
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
text box and SqlDecimal datatypes Mark ASP .Net 2 11-07-2005 05:34 PM
Specified cast not valid on decimal & double datatypes .Net Sports ASP .Net 1 08-31-2005 09:11 AM
defining or not defining destructors johny smith C++ 8 07-02-2004 08:51 AM
Problem while reading excel file with mix datatypes =?Utf-8?B?UGF1cmF2aQ==?= ASP .Net 1 03-04-2004 03:11 AM
interrogating database for field names/datatypes? ASP .Net 2 07-28-2003 01:39 AM



Advertisments