Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with Turbo C ) - <b>abs() calculate absolute value of integer</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 abs()                   Calculate Absolute Value of Integer

 #include   <stdlib.h>                   For function declarations

 int        abs(n);
 int        n;                           Integer value

    abs() returns the absolute value of an integer, 'n', in the range 0
    through 32767 (note: -32768 is returned as -32768).

       Returns:     Absolute value of 'n'

          Note:     If <stdlib.h> is included, and #undef abs() has not
                    been added to <stdlib.h>, then abs() will be treated
                    as a macro.

   -------------------------------- Example ---------------------------------

    The following statements calculate the absolute values of -15, 0 and
    33.

           #include <stdlib.h>     /* Required for function declaration only
           */

           main()
           {
               int x, y, z;

               x = abs(-15);  /* x = 15 */
               y = abs(0);    /* y =  0 */
               z = abs(33);   /* z = 33 */
           }


See Also: cabs() fabs() labs()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson