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

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!ames!daffodil!wyvern!waggen!alpha
  3. From: alpha@waggen.twuug.com (Joe Wright)
  4. Subject: Re: the abs() function in C
  5. Message-ID: <1992Nov22.022357.20377@waggen.twuug.com>
  6. Organization: ALPHA, Box 68621, Va. Beach, VA 23455
  7. X-Newsreader: TIN [version 1.1 PL6]
  8. References: <pebi.722223424@zephyr.aem.umn.edu>
  9. Date: Sun, 22 Nov 1992 02:23:57 GMT
  10. Lines: 19
  11.  
  12. Peter A. Bidian (pebi@aem.umn.edu) wrote:
  13. : Isn't abs(-2)=2 in C?
  14. : I always get 0.
  15. : Confused!
  16.  
  17. This is almost always a macro like:
  18.  
  19. #define abs(x) ((x)>=0 ? (x) : -(x))
  20.  
  21. Some systems have abs(), fabs(), labs(), etc., as functions.
  22. Look around.  Maybe you can simply declare it ..
  23.  
  24.     extern int abs();
  25.  
  26. -- 
  27. Joe Wright  alpha@waggen.twuug.com  
  28. "If we could only see the source code.."  (Dave Olson)
  29.