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

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!psinntp!cadkey!dennis
  3. From: dennis@cadkey.com (Dennis Paul Himes)
  4. Subject: Re: WHAT WENT WRONG?
  5. Message-ID: <1992Dec19.010016.15078@cadkey.com>
  6. Organization: cadkey
  7. References: <10441.107.uupcb@cutting.hou.tx.us>
  8. Date: Sat, 19 Dec 1992 01:00:16 GMT
  9. Lines: 30
  10.  
  11. In article <10441.107.uupcb@cutting.hou.tx.us> david.brooks@cutting.hou.tx.us (David Brooks)  writes:
  12. >The following code is intended to compute the factorial of a given
  13. >number. Unfortunately it gives weird results for numbers larger than 12
  14. >or so...
  15. >
  16. >    double x,y;
  17. >
  18. >  [stuff deleted]
  19. >
  20. >    scanf("%d", &x);
  21. >
  22. >  [stuff deleted]
  23. >
  24. >    printf("\nFactorial= %d\n", x);
  25. >
  26. >  [stuff deleted]
  27. >
  28. >Undoubtedly the problem comes from playing with numbers that are too
  29. >big. Is there something obvious that I am overlooking here?
  30. >
  31. >  [stuff deleted]
  32. >
  33.      Yes.  You're using %d for a double.  Use %lf instead.
  34.  
  35. ==============================================================================
  36.  
  37.                Dennis Paul Himes    <>    dennis@cadkey.com
  38.  
  39. "In watermelon sugar the deeds were done and done again as my life is done
  40. in watermelon sugar."           - Richard Brautigan
  41.