home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!psinntp!cadkey!dennis
- From: dennis@cadkey.com (Dennis Paul Himes)
- Subject: Re: WHAT WENT WRONG?
- Message-ID: <1992Dec19.010016.15078@cadkey.com>
- Organization: cadkey
- References: <10441.107.uupcb@cutting.hou.tx.us>
- Date: Sat, 19 Dec 1992 01:00:16 GMT
- Lines: 30
-
- 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...
- >
- > double x,y;
- >
- > [stuff deleted]
- >
- > scanf("%d", &x);
- >
- > [stuff deleted]
- >
- > printf("\nFactorial= %d\n", x);
- >
- > [stuff deleted]
- >
- >Undoubtedly the problem comes from playing with numbers that are too
- >big. Is there something obvious that I am overlooking here?
- >
- > [stuff deleted]
- >
- Yes. You're using %d for a double. Use %lf instead.
-
- ==============================================================================
-
- Dennis Paul Himes <> dennis@cadkey.com
-
- "In watermelon sugar the deeds were done and done again as my life is done
- in watermelon sugar." - Richard Brautigan
-