home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / c / 18537 < prev    next >
Encoding:
Text File  |  1992-12-17  |  1.8 KB  |  54 lines

  1. Newsgroups: comp.lang.c
  2. 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
  3. From: bketcham@stein.u.washington.edu (Benjamin Ketcham)
  4. Subject: Re: WHAT WENT WRONG?
  5. Message-ID: <1992Dec17.175008.450@u.washington.edu>
  6. Sender: news@u.washington.edu (USENET News System)
  7. Organization: University of Washington, Seattle
  8. References: <10441.107.uupcb@cutting.hou.tx.us>
  9. Date: Thu, 17 Dec 1992 17:50:08 GMT
  10. Lines: 42
  11.  
  12. In article <10441.107.uupcb@cutting.hou.tx.us> david.brooks@cutting.hou.tx.us (David Brooks)  writes:
  13. >The following code is intended to compute the factorial of a given
  14. >number. Unfortunately it gives weird results for numbers larger than 12
  15. >or so... Does anyone have an idea why? I tried compiling it under Huge
  16. >memory model and still the same effects.                          ^^^^
  17.  ^^^^^^^^^^^^
  18.  
  19. AAAAAAAAAAAAGGGHHHHHHH!!!!!!!
  20.  
  21. >
  22. >#include <stdio.h>
  23. >
  24. >main()
  25. >{
  26. >    double x, y;
  27. >
  28. >    printf("\nEnter number to factorialize:");
  29. >    scanf("%d", &x);
  30. >
  31. >    for(y=x-1;y>1;y--) x*=y;
  32. >
  33. >    printf("\nFactorial= %d\n", x);
  34. >}                        ^^ 
  35.  
  36. AAAAAAAAAAAAGGGHHHHHHH!!!!!!!
  37.  
  38. >
  39. >
  40. >Undoubtedly the problem comes from playing with numbers that are too
  41. >big. Is there something obvious that I am overlooking here? Or is there
  42. >some hidden secret for dealing with big numbers that only rocket
  43. >scientists and C gurus are aware of? Any help is appreciated!
  44. >
  45. >   David
  46. >                                                   
  47. >----
  48. >+---------------------------------------------------------------------+
  49. >| The Cutting Edge BBS (cutting.hou.tx.us)    A PCBoard 14.5a system  |
  50. >| Houston, Texas, USA    +1 713 466 1525          running uuPCB       |
  51. >+---------------------------------------------------------------------+
  52.  
  53.  
  54.