Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Turbo C - <b>fabs() calculate absolute value of floating-point value</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
fabs()                   Calculate Absolute Value of Floating-Point Value

 #include   <math.h>

 double     fabs(x);
 double     x;                           Floating-point value

    fabs() returns the absolute value of the double 'x'.

    Returns:    The absolute value of 'x'. There is no error return.

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

    The following statements calculate the absolute values of -15.7, 0.0
    and 4.66e-3.

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

         main()
         {
             double x, y, z;

             x = fabs(-15.7);     /* x = 15.7 */
             y = fabs(0.0);       /* y = 0.0 */
             z = fabs(4.66e-3);   /* z = 4.66e-3 (0.00466) */
         }

See Also: ceil() fmod()

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