473,729 Members | 2,272 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

very very very long integer

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..
Nov 14 '05 #1
19 7270
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.
Nov 14 '05 #2
"shanx__=|;-" <ch**********@y ahoo.com> wrote in message
news:42******** *************** ***@posting.goo gle.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
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- e-mail contact form
Nov 14 '05 #3
"Ivan Vecerina" <pl************ *****@ivan.vece rina.com> wrote in message news:<ck******* ***@newshispeed .ch>...
"shanx__=|;-" <ch**********@y ahoo.com> wrote in message
news:42******** *************** ***@posting.goo gle.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 999448849493945 848385845868546 854 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...
Nov 14 '05 #4
"Ivan Vecerina" <pl************ *****@ivan.vece rina.com> wrote in message news:<ck******* ***@newshispeed .ch>...
"shanx__=|;-" <ch**********@y ahoo.com> wrote in message
news:42******** *************** ***@posting.goo gle.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


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..
Nov 14 '05 #5
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,buffe r);
printf("%s\n",b uffer);
}
933262154439441 526816992388562 667004907159682 643816214685929 638952175999932 299156089414639
761565182862536 979208272237582 511852109168640 000000000000000 00000000
http://www.cs.virginia.edu/~lcc-win32
Nov 14 '05 #6
shanx__=|;- wrote:
"Ivan Vecerina" <pl************ *****@ivan.vece rina.com> wrote in message news:<ck******* ***@newshispeed .ch>...
"shanx__=|;-" <ch**********@y ahoo.com> wrote in message
news:42****** *************** *****@posting.g oogle.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 999448849493945 848385845868546 854 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/
Nov 14 '05 #7
On Sat, 16 Oct 2004 20:50:26 +0200
jacob navia <ja***@jacob.re mcomp.fr> 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.
Nov 14 '05 #8
Flash Gordon wrote:
On Sat, 16 Oct 2004 20:50:26 +0200
jacob navia <ja***@jacob.re mcomp.fr> 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
distributio n.
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.

Nov 14 '05 #9
Flash Gordon wrote:
On Sat, 16 Oct 2004 20:50:26 +0200
jacob navia <ja***@jacob.re mcomp.fr> 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
distributio n.
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,buffe r);
printf("%s\n",b uffer);
}
933262154439441 526816992388562 667004907159682 643816214685929 638952175999932 299156089414639
761565182862536 979208272237582 511852109168640 000000000000000 00000000
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,long2 quad(1),b);
n--;
}
return r;
}

Great deal.
Nov 14 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
6347
by: Allcomp | last post by:
Hello, I have seen something really strange in VB6 If I do a Int ( (5 * 1.2)) , I receive the value 5, but I should receive 6? Is this a bug or something really "normal". I can see that if I do ? int ((5 * 1.2 + 0.0000000000000003)) I receive 6. If I add something smaller, I have 5 as a result What is strange is that If I do a ? 5*1.2, I receive 6 so (5 * 1.2)
45
7462
by: Trevor Best | last post by:
I did a test once using a looping variable, first dimmed as Integer, then as Long. I found the Integer was quicker at looping. I knew this to be true back in the 16 bit days where the CPU's (80286) word size was 16 bits same as an integer. Now with a 32 bit CPU I would have expected the long to be faster as it's the same size as the CPU's word size so wouldn't need sawing in half like a magician's assistant to calculate on like an...
4
2304
by: Abhishek Jha | last post by:
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 abhishekjha10@yahoo.co.in
9
7134
by: rsine | last post by:
I have developed a program that sends a command through the serial port to our business system and then reads from the buffer looking for a number. Everything worked great on my WinXP system, but when I tried the program on the Win98 system it will be running on, I get the following error: Cast from string "2076719" to type 'Long' is not valid I am not sure why I only get this error on the Win98 system or how to go about correcting...
12
2201
by: Jack Daly | last post by:
I've inherited some code which uses an undocumented feature of a third-party vendor's library. Essentially, this vendor has kept the details of an interface struct secret, but we can pass a pointer to this struct to other vendor routines. The struct describes a complex time-varying object, but it basically boils down to an integer, and there are access routines to get to the current value of this integer. My problem is: 1) Our code is...
13
1713
by: Jack B | last post by:
I'm using Access 2002 to create a database for a small opera company that my wife is involved in, and I'm more than a bit rusty because I haven't created a new Access database since about 1999. So, I will probably have quite a few questions as I go through this, and hopefully this group will help me out. I will be creating this database for someone else to enter the data. I have a patron table with name, address, email, etc., and I...
12
13498
by: Ahmad Jalil Qarshi | last post by:
Hi, I have an integer value which is very long like 9987967441778573855. Now I want to convert it into equivalent Hex value. The result must be 8A9C63784361021F I have used sprintf(pHex,"%0X",9987967441778573855). But it only returns 8
4
2450
by: Tim | last post by:
Hello All, I could use some help on an error that is just now popping it's head up. Seems that the autoincrement numeric has hit 32,767. The autoincrement is used in various locations in the database, but in this case (log sheets), we have hit 32k log entries over the past 2 years. Is there a simple switch to set the autoincrement from integer to long integer?
0
22463
by: zephyrus360 | last post by:
This is about a technique to find the mod of a very large integer with a normal small integer. I recently encountered this problem when I needed to compute the modulus of a very large number with a normal integer. I needed this in a C++ program running on a 32-bit UNIX platform. The problem was that the number was 28 digits long and no native datatype in c++ could store a number of that size. (Eg: 1088263455689473669888943602 % 380) Not...
0
8761
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9281
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9142
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8148
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6022
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3238
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2680
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2163
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.