home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / crt / src / abs.c < prev    next >
C/C++ Source or Header  |  1998-06-17  |  900b  |  41 lines

  1. /***
  2. *abs.c - find absolute value
  3. *
  4. *       Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. *       defines abs() - find the absolute value of an int.
  8. *
  9. *******************************************************************************/
  10.  
  11. #include <cruntime.h>
  12. #include <stdlib.h>
  13.  
  14. #ifdef _WIN32
  15. #pragma function(abs)
  16. #endif  /* _WIN32 */
  17.  
  18. /***
  19. *int abs(number) - find absolute value of number
  20. *
  21. *Purpose:
  22. *       Returns the absolute value of number (if number >= 0, returns number,
  23. *       else returns -number).
  24. *
  25. *Entry:
  26. *       int number - number to find absolute value of
  27. *
  28. *Exit:
  29. *       returns the aboslute value of number
  30. *
  31. *Exceptions:
  32. *
  33. *******************************************************************************/
  34.  
  35. int __cdecl abs (
  36.         int number
  37.         )
  38. {
  39.         return( number>=0 ? number : -number );
  40. }
  41.