Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.4 KiB

  1. /***
  2. *labs.c - find absolute value of a long integer
  3. *
  4. * Copyright (c) 1985-1991, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * defines labs() - find absolute value of a long integer.
  8. *
  9. *Revision History:
  10. * 03-15-84 RN initial version
  11. * 04-22-87 JMB added function pragma for conversion to C 5.0 compiler
  12. * 12-11-87 JCR Added "_LOAD_DS" to declaration
  13. * 03-14-90 GJF Replaced _LOAD_DS with _CALLTYPE1, added #include
  14. * <cruntime.h> and fixed the copyright. Also, cleaned
  15. * up the formatting a bit.
  16. * 10-04-90 GJF New-style function declarator.
  17. * 12-28-90 SRW Added _CRUISER_ conditional around function pragma
  18. * 04-01-91 SRW Enable #pragma function for i386 _WIN32_ builds too.
  19. * 03-09-94 RDL Enable #pragma function for i386 _WIN32_ builds too.
  20. *
  21. *******************************************************************************/
  22. #include <cruntime.h>
  23. #include <stdlib.h>
  24. #ifdef _MSC_VER
  25. #pragma function(labs)
  26. #endif
  27. /***
  28. *long labs(lnumber) - find absolute value of long.
  29. *
  30. *Purpose:
  31. * Find the absolute value of a long integer (lnumber if lnumber >= 0),
  32. * -lnumber if lnumber < 0).
  33. *
  34. *Entry:
  35. * long lnumber - number to find absolute value of
  36. *
  37. *Exit:
  38. * returns the absolute value of lnumber
  39. *
  40. *Exceptions:
  41. *
  42. *******************************************************************************/
  43. long _CALLTYPE1 labs (
  44. long lnumber
  45. )
  46. {
  47. return( lnumber>=0L ? lnumber : -lnumber );
  48. }