1 /* 2 FUNCTION 3 <<labs>>---long integer absolute value 4 5 INDEX 6 labs 7 8 ANSI_SYNOPSIS 9 #include <stdlib.h> 10 long labs(long <[i]>); 11 12 TRAD_SYNOPSIS 13 #include <stdlib.h> 14 long labs(<[i]>) 15 long <[i]>; 16 17 DESCRIPTION 18 <<labs>> returns 19 @tex 20 $|x|$, 21 @end tex 22 the absolute value of <[i]> (also called the magnitude 23 of <[i]>). That is, if <[i]> is negative, the result is the opposite 24 of <[i]>, but if <[i]> is nonnegative the result is <[i]>. 25 26 The similar function <<abs>> uses and returns <<int>> rather than 27 <<long>> values. 28 29 RETURNS 30 The result is a nonnegative long integer. 31 32 PORTABILITY 33 <<labs>> is ANSI. 34 35 No supporting OS subroutine calls are required. 36 */ 37 38 #include <stdlib.h> 39 40 long 41 _DEFUN (labs, (x), 42 long x) 43 { 44 if (x < 0) 45 { 46 x = -x; 47 } 48 return x; 49 } 50