OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.17.0/] [newlib/] [libc/] [stdlib/] [abs.c] - Blame information for rev 158

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
/*
2
FUNCTION
3
<<abs>>---integer absolute value (magnitude)
4
 
5
INDEX
6
        abs
7
 
8
ANSI_SYNOPSIS
9
        #include <stdlib.h>
10
        int abs(int <[i]>);
11
 
12
TRAD_SYNOPSIS
13
        #include <stdlib.h>
14
        int abs(<[i]>)
15
        int <[i]>;
16
 
17
DESCRIPTION
18
<<abs>> 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 <<labs>> uses and returns <<long>> rather than <<int>> values.
27
 
28
RETURNS
29
The result is a nonnegative integer.
30
 
31
PORTABILITY
32
<<abs>> is ANSI.
33
 
34
No supporting OS subroutines are required.
35
*/
36
 
37
#include <stdlib.h>
38
 
39
int
40
_DEFUN (abs, (i), int i)
41
{
42
  return (i < 0) ? -i : i;
43
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.