home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / c / 16960 < prev    next >
Encoding:
Text File  |  1992-11-21  |  1.1 KB  |  36 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!jvnc.net!princeton!csservices!kastle!blume
  3. From: blume@kastle.Princeton.EDU (Matthias Blume)
  4. Subject: Re: the abs() function in C
  5. Message-ID: <1992Nov21.015518.20743@csservices.Princeton.EDU>
  6. Sender: news@csservices.Princeton.EDU (USENET News System)
  7. Reply-To: blume@kastle.Princeton.EDU (Matthias Blume)
  8. Organization: Dept. of Computer Science, Princeton University
  9. References: <pebi.722223424@zephyr.aem.umn.edu> <maurer.722246649@magellan.stanford.edu>
  10. Date: Sat, 21 Nov 1992 01:55:18 GMT
  11. Lines: 23
  12.  
  13. In article <maurer.722246649@magellan.stanford.edu>,
  14. maurer@nova.stanford.edu (Michael Maurer) writes:
  15. |> In <pebi.722223424@zephyr.aem.umn.edu> pebi@aem.umn.edu (Peter A.
  16. Bidian) writes:
  17. |> 
  18. |> 
  19. |> >Isn't abs(-2)=2 in C?
  20. |> >I always get 0.
  21.  
  22. Please, show the full program text, where you encountered the problem.
  23. Of course, abs(-2) should be 2.
  24.  
  25. |> 
  26. |> >Confused!
  27. |> 
  28. |> >Peter
  29. |> 
  30. |> you probably want to say abs(-2.0), if the abs() function expects a
  31. |> floating point argument.  or abs((double)-2).
  32.  
  33. abs is an int-function!  For doubles we've got fabs!
  34.  
  35. -Matthias
  36.