Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > very very very long integer

Reply
Thread Tools

very very very long integer

 
 
shanx__=|;-
Guest
Posts: n/a
 
      10-16-2004
hi i need some help regarding use of very very long integer datatype
in 'c'.. i need it to store result of large number's factorial..

if someone can healp it would be a delight..
 
Reply With Quote
 
 
 
 
Karthik Kumar
Guest
Posts: n/a
 
      10-16-2004
shanx__=|;- wrote:
> hi i need some help regarding use of very very long integer datatype
> in 'c'.. i need it to store result of large number's factorial..
>
> if someone can healp it would be a delight..


As such C cannot support it.
But what you could do is to implement a linked list of long
integers yourselves and define the operations accordingly.
That would be interesting.
 
Reply With Quote
 
 
 
 
Ivan Vecerina
Guest
Posts: n/a
 
      10-16-2004
"shanx__=|;-" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> hi i need some help regarding use of very very long integer datatype
> in 'c'.. i need it to store result of large number's factorial..
>
> if someone can healp it would be a delight..

Someone, or something ?
http://www.google.com/search?q=bigint+C+library

Several 'big integer' libraries have already been implemented.


hth -Ivan
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- e-mail contact form


 
Reply With Quote
 
shanx__=|;-
Guest
Posts: n/a
 
      10-16-2004
"Ivan Vecerina" <(E-Mail Removed)> wrote in message news:<ckqvqf$b2a$(E-Mail Removed)>...
> "shanx__=|;-" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) om...
> > hi i need some help regarding use of very very long integer datatype
> > in 'c'.. i need it to store result of large number's factorial..
> >
> > if someone can healp it would be a delight..

> Someone, or something ?
> http://www.google.com/search?q=bigint+C+library
>
> Several 'big integer' libraries have already been implemented.
>
>
> hth -Ivan


i actually need to use the datatype to find factorial of any number n
the ans may be anything like 999448849493945848385845868546854 so
need that sort of integer datatype.... i know ive to build this my
self. ya one option can be linked list of long integers. thanx for
replyin...
 
Reply With Quote
 
shanx__=|;-
Guest
Posts: n/a
 
      10-16-2004
"Ivan Vecerina" <(E-Mail Removed)> wrote in message news:<ckqvqf$b2a$(E-Mail Removed)>...
> "shanx__=|;-" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) om...
> > hi i need some help regarding use of very very long integer datatype
> > in 'c'.. i need it to store result of large number's factorial..
> >
> > if someone can healp it would be a delight..

> Someone, or something ?
> http://www.google.com/search?q=bigint+C+library
>
> Several 'big integer' libraries have already been implemented.
>
>
> hth -Ivan


ya i know that there are several lib's there with which we can use
bigger integers , but the point is i wanna have my own datatype.. i
wanna know how this thing can be done eg. using linked list is one
way..

thanx for ur repy..
 
Reply With Quote
 
jacob navia
Guest
Posts: n/a
 
      10-16-2004
shanx__=|;- wrote:
> hi i need some help regarding use of very very long integer datatype
> in 'c'.. i need it to store result of large number's factorial..
>
> if someone can healp it would be a delight..

The lcc-win32 compiler comes with a bignum package in the standard
distribution.
This is an extension to the C language of lcc-win32.
#include <stdio.h>
#include <bignums.h>
pBignum factorial(int n)
{
pBignum b = 1,r=1;

while (n) {
r = b*r;
b++;
n--;
}
return r;
}
int main(void)
{
pBignum b = factorial(100);
char buffer[4096];

quadtoa(b,buffer);
printf("%s\n",buffer);
}
93326215443944152681699238856266700490715968264381 6214685929638952175999932299156089414639
76156518286253697920827223758251185210916864000000 000000000000000000
http://www.cs.virginia.edu/~lcc-win32
 
Reply With Quote
 
=?ISO-8859-1?Q?=22Nils_O=2E_Sel=E5sdal=22?=
Guest
Posts: n/a
 
      10-16-2004
shanx__=|;- wrote:
> "Ivan Vecerina" <(E-Mail Removed)> wrote in message news:<ckqvqf$b2a$(E-Mail Removed)>...
>
>>"shanx__=|;-" <(E-Mail Removed)> wrote in message
>>news:(E-Mail Removed) .com...
>>
>>>hi i need some help regarding use of very very long integer datatype
>>>in 'c'.. i need it to store result of large number's factorial..
>>>
>>>if someone can healp it would be a delight..

>>
>>Someone, or something ?
>> http://www.google.com/search?q=bigint+C+library
>>
>>Several 'big integer' libraries have already been implemented.
>>
>>
>>hth -Ivan

>
>
> i actually need to use the datatype to find factorial of any number n
> the ans may be anything like 999448849493945848385845868546854 so
> need that sort of integer datatype.... i know ive to build this my
> self. ya one option can be linked list of long integers. thanx for
> replyin...


Check if you can use gmp.
http://www.swox.com/gmp/
 
Reply With Quote
 
Flash Gordon
Guest
Posts: n/a
 
      10-16-2004
On Sat, 16 Oct 2004 20:50:26 +0200
jacob navia <(E-Mail Removed)> wrote:

> shanx__=|;- wrote:
> > hi i need some help regarding use of very very long integer datatype
> > in 'c'.. i need it to store result of large number's factorial..
> >
> > if someone can healp it would be a delight..

> The lcc-win32 compiler comes with a bignum package in the standard
> distribution.
> This is an extension to the C language of lcc-win32.
> #include <stdio.h>
> #include <bignums.h>


<snip>

Are you offering to provide the source code (implemented in standard C,
not your strange language) for this library to the OP for free? If not
then stop advertising your compiler and libraries for a language similar
to C.
--
Flash Gordon
Sometimes I think shooting would be far too good for some people.
Although my email address says spam, it is real and I read it.
 
Reply With Quote
 
jacob navia
Guest
Posts: n/a
 
      10-16-2004
Flash Gordon wrote:
> On Sat, 16 Oct 2004 20:50:26 +0200
> jacob navia <(E-Mail Removed)> wrote:
>
>
>>shanx__=|;- wrote:
>>
>>>hi i need some help regarding use of very very long integer datatype
>>>in 'c'.. i need it to store result of large number's factorial..
>>>
>>>if someone can healp it would be a delight..

>>
>>The lcc-win32 compiler comes with a bignum package in the standard
>>distribution.
>>This is an extension to the C language of lcc-win32.
>>#include <stdio.h>
>>#include <bignums.h>

>
>
> <snip>
>
> Are you offering to provide the source code (implemented in standard C,
> not your strange language) for this library to the OP for free? If not
> then stop advertising your compiler and libraries for a language similar
> to C.

 
Reply With Quote
 
jacob navia
Guest
Posts: n/a
 
      10-16-2004
Flash Gordon wrote:
> On Sat, 16 Oct 2004 20:50:26 +0200
> jacob navia <(E-Mail Removed)> wrote:
>
>
>>shanx__=|;- wrote:
>>
>>>hi i need some help regarding use of very very long integer datatype
>>>in 'c'.. i need it to store result of large number's factorial..
>>>
>>>if someone can healp it would be a delight..

>>
>>The lcc-win32 compiler comes with a bignum package in the standard
>>distribution.
>>This is an extension to the C language of lcc-win32.
>>#include <stdio.h>
>>#include <bignums.h>

>
>
> <snip>
>
> Are you offering to provide the source code (implemented in standard C,
> not your strange language) for this library to the OP for free? If not
> then stop advertising your compiler and libraries for a language similar
> to C.

The library is written by Mr Mike Scott, for the first time in 1989. I
rewrote most of it in 386 asm, and it is quite fast now. The newer
versions of this library are available in standard C at:
ftp.compapp.dcu.ie/pub/crypto/miracl.zip

It has a C++ interface, very similar to what my compiler does.
Number operations can be used to naturally express operations on
numbers.

I had cancelled my message. I cancelled it 5 minutes after I sent
it, so you are really fast. Congratulations.

I put here the rest of my message for documentation, since
I cancelled it:

#include <stdio.h>
#include <bignums.h>
pBignum factorial(int n)
{
pBignum b = 1,r=1;

while (n) {
r = b*r;
b++;
n--;
}
return r;
}
int main(void)
{
pBignum b = factorial(100);
char buffer[4096];

quadtoa(b,buffer);
printf("%s\n",buffer);
}
93326215443944152681699238856266700490715968264381 6214685929638952175999932299156089414639
76156518286253697920827223758251185210916864000000 000000000000000000
http://www.cs.virginia.edu/~lcc-win32

In standard C that would be:
pBignum factorial(int n)
{
pBignum b = long2quad(1);
pBignum r=long2quad(1);

while (n) {
quadmult(b,r,r);
quadadd(b,long2quad(1),b);
n--;
}
return r;
}

Great deal.
 
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
Size of Integer , long Integer, Long double Suresh V C++ 5 07-05-2010 08:09 AM
Having compilation error: no match for call to (const __gnu_cxx::hash<long long int>) (const long long int&) veryhotsausage C++ 1 07-04-2008 05:41 PM
very very very long integer Abhishek Jha C Programming 4 10-17-2004 08:19 AM
Re: long long integer and double precision number cyberdude C Programming 2 06-25-2003 07:54 PM
Re: long long integer and double precision number Dan Pop C Programming 0 06-24-2003 12:11 PM



Advertisments