File: abs.3

package info (click to toggle)
manpages 6.03-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 18,720 kB
  • sloc: perl: 3,144; sh: 497; python: 181; makefile: 108; lisp: 22
file content (111 lines) | stat: -rw-r--r-- 2,376 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
'\" t
.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
.\"
.\" SPDX-License-Identifier: Linux-man-pages-copyleft
.\"
.\" References consulted:
.\"     Linux libc source code
.\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
.\"     386BSD man pages
.\" Modified Mon Mar 29 22:31:13 1993, David Metcalfe
.\" Modified Sun Jun  6 23:27:50 1993, David Metcalfe
.\" Modified Sat Jul 24 21:45:37 1993, Rik Faith (faith@cs.unc.edu)
.\" Modified Sat Dec 16 15:02:59 2000, Joseph S. Myers
.\"
.TH abs 3 2022-12-29 "Linux man-pages 6.03"
.SH NAME
abs, labs, llabs, imaxabs \- compute the absolute value of an integer
.SH LIBRARY
Standard C library
.RI ( libc ", " \-lc )
.SH SYNOPSIS
.nf
.B #include <stdlib.h>
.PP
.BI "int abs(int " j );
.BI "long labs(long " j );
.BI "long long llabs(long long " j );
.PP
.B #include <inttypes.h>
.PP
.BI "intmax_t imaxabs(intmax_t " j );
.fi
.PP
.RS -4
Feature Test Macro Requirements for glibc (see
.BR feature_test_macros (7)):
.RE
.PP
.BR llabs ():
.nf
    _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
.fi
.SH DESCRIPTION
The
.BR abs ()
function computes the absolute value of the integer
argument \fIj\fP.
The
.BR labs (),
.BR llabs (),
and
.BR imaxabs ()
functions compute the absolute value of the argument \fIj\fP of the
appropriate integer type for the function.
.SH RETURN VALUE
Returns the absolute value of the integer argument, of the appropriate
integer type for the function.
.SH ATTRIBUTES
For an explanation of the terms used in this section, see
.BR attributes (7).
.ad l
.nh
.TS
allbox;
lbx lb lb
l l l.
Interface	Attribute	Value
T{
.BR abs (),
.BR labs (),
.BR llabs (),
.BR imaxabs ()
T}	Thread safety	MT-Safe
.TE
.hy
.ad
.sp 1
.SH STANDARDS
POSIX.1-2001, POSIX.1-2008, C99, SVr4, 4.3BSD.
.SH NOTES
Trying to take the absolute value of the most negative integer
is not defined.
.PP
The
.BR llabs ()
function is included since glibc 2.0.
The
.BR imaxabs ()
function is included since glibc 2.1.1.
.PP
For
.BR llabs ()
to be declared, it may be necessary to define
\fB_ISOC99_SOURCE\fP or \fB_ISOC9X_SOURCE\fP (depending on the
version of glibc) before including any standard headers.
.PP
By default,
GCC handles
.BR abs (),
.BR labs (),
and (since GCC 3.0)
.BR llabs ()
and
.BR imaxabs ()
as built-in functions.
.SH SEE ALSO
.BR cabs (3),
.BR ceil (3),
.BR fabs (3),
.BR floor (3),
.BR rint (3)