home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!usenet.coe.montana.edu!news.u.washington.edu!stein.u.washington.edu!bketcham
- From: bketcham@stein.u.washington.edu (Benjamin Ketcham)
- Subject: Re: WHAT WENT WRONG?
- Message-ID: <1992Dec17.175008.450@u.washington.edu>
- Sender: news@u.washington.edu (USENET News System)
- Organization: University of Washington, Seattle
- References: <10441.107.uupcb@cutting.hou.tx.us>
- Date: Thu, 17 Dec 1992 17:50:08 GMT
- Lines: 42
-
- In article <10441.107.uupcb@cutting.hou.tx.us> david.brooks@cutting.hou.tx.us (David Brooks) writes:
- >The following code is intended to compute the factorial of a given
- >number. Unfortunately it gives weird results for numbers larger than 12
- >or so... Does anyone have an idea why? I tried compiling it under Huge
- >memory model and still the same effects. ^^^^
- ^^^^^^^^^^^^
-
- AAAAAAAAAAAAGGGHHHHHHH!!!!!!!
-
- >
- >#include <stdio.h>
- >
- >main()
- >{
- > double x, y;
- >
- > printf("\nEnter number to factorialize:");
- > scanf("%d", &x);
- >
- > for(y=x-1;y>1;y--) x*=y;
- >
- > printf("\nFactorial= %d\n", x);
- >} ^^
-
- AAAAAAAAAAAAGGGHHHHHHH!!!!!!!
-
- >
- >
- >Undoubtedly the problem comes from playing with numbers that are too
- >big. Is there something obvious that I am overlooking here? Or is there
- >some hidden secret for dealing with big numbers that only rocket
- >scientists and C gurus are aware of? Any help is appreciated!
- >
- > David
- >
- >----
- >+---------------------------------------------------------------------+
- >| The Cutting Edge BBS (cutting.hou.tx.us) A PCBoard 14.5a system |
- >| Houston, Texas, USA +1 713 466 1525 running uuPCB |
- >+---------------------------------------------------------------------+
-
-
-