473,588 Members | 2,527 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

-1.#IND000 problem

2 New Member
I am working on code to calculate the factorial using below function:

int factorial (int num)
{
if (num==1)
return 1;
return factorial(num-1)*num; // recursive call
}


And I need to calculate the numbers from 1 to 255…

The problem occurs when it reaches number 35 and above, it starts to give -1.#IND000 as result for the calculation…

I tried to define the variable as float, double , long double but it doesn’t work!
May 25 '08 #1
6 5386
Laharl
849 Recognized Expert Contributor
Those numbers are far too large for even long doubles. You'll need to find (or write) a library capable of working with such huge numbers.
May 25 '08 #2
Motoma
3,237 Recognized Expert Specialist
Hi iCe CreaM,

You will want to take a look at an Arbitrary-precision arithmetic library, or else create your own to help with this task.
If you take a look at the article I hyperlinked, there is a section mentioning factorials!

Good luck,
Motoma


I am working on code to calculate the factorial using below function:

int factorial (int num)
{
if (num==1)
return 1;
return factorial(num-1)*num; // recursive call
}


And I need to calculate the numbers from 1 to 255…

The problem occurs when it reaches number 35 and above, it starts to give -1.#IND000 as result for the calculation…

I tried to define the variable as float, double , long double but it doesn’t work!
May 26 '08 #3
iCe CreaM
2 New Member
first of all thanks guys for your replies...

i gounf the library http://gmplib.org/#WHAT

they said that it is the best in this regard but i couldn't know how to install it or use it in my C++ program :(

i tried to read the manual but no result...

thanks.
May 26 '08 #4
sicarie
4,677 Recognized Expert Moderator Specialist
So what is your question, and what have you tried?
May 27 '08 #5
RedSon
5,000 Recognized Expert Expert
So what is your question, and what have you tried?
Just for fun 170! is:

725741562 followed by 298 zeros, give or take. Or in notation its 7.25741562 × 10^306
May 27 '08 #6
JosAH
11,448 Recognized Expert MVP
Just because people can't comprehend the size of factorials, maybe Stirling's
approximation can be of any insight:

ln(n!) ~= n*ln(n)-n

Just plug in some values for n and play with your calculator ;-)

kind regards,

Jos
May 28 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
3058
by: Bruce Davis | last post by:
I'm having a problem on windows (both 2000 and XP) with a multi-threaded tkinter gui application. The problem appears to be a deadlock condition when a child thread pops up a Pmw dialog window in the context of a main window. The problem does not occur on HPUX or Linux. The following simple example code illustrates the problem and the work around I've come up with; However, I'd like, very much, to get rid of the kludgy work around....
11
3744
by: Kostatus | last post by:
I have a virtual function in a base class, which is then overwritten by a function of the same name in a publically derived class. When I call the function using a pointer to the derived class (ClassB* b; b->func(); ) the base-class function is called instead of the new function in the derived class. All other similar functions (virtual in the base class and overwritten in the the derived class) work fine, it's just this one function. ...
0
2016
by: Refky Wahib | last post by:
Hi I need Technical Support I finished a Great project using .Net and SQL Server and .Net Mobile Control My Business case is to implement this Program to accept about 1 Million concurrent users So I designed the project as master Node that has all administration
117
7151
by: Peter Olcott | last post by:
www.halting-problem.com
28
5194
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass(); .... and then call the virtual method, why is it that the base class's method is called instead of the overridden method? How do I fix this if I don't know at runtime what the child class is? I'm using Activator.CreateInstance() to load the...
6
3793
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length is more that 1249 bytes, then the progress bar of the browser will move too slow and then displaying that the page not found!!!! If the message is less than or equal to 1249 then no problem.
16
4889
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by Microsoft must be installed on their servers. Now german Umlaute (ä, ü, ö) and quotes are returned incorrectly in SOAP fault responses. This can be easily verified: Implement the following in a web service method (just raises a SOAPException with a...
2
4541
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was set to...it is set to false. Can someone show me what I am doing wrong and tell me the correct way? Thank you. In the page load event, I am doing the following:
2
3826
by: Zongwen | last post by:
this problem happened after we upgrade our program from vc6.0 to vc.net2003 unmanaged code. Following are the sample code: float p, cpr = 3.4028234663852886e+038; p = (1.0f - pow(1.0f-cpr/100.0f, 1.0f/12.0f)); if(p<0.0f) p = 0.0; ==
0
7929
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7860
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
8354
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
8223
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
6634
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...
0
3847
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3883
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2371
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
0
1195
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.