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

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