Changeset View
Changeset View
Standalone View
Standalone View
lib/libc/stdlib/abs.3
| .\" Copyright (c) 1990, 1991, 1993 | .\" Copyright (c) 1990, 1991, 1993 | ||||
| .\" The Regents of the University of California. All rights reserved. | .\" The Regents of the University of California. All rights reserved. | ||||
| .\" Copyright (c) 2026 Aymeric Wibo <obiwac@freebsd.org> | |||||
| .\" | .\" | ||||
| .\" This code is derived from software contributed to Berkeley by | .\" This code is derived from software contributed to Berkeley by | ||||
| .\" the American National Standards Committee X3, on Information | .\" the American National Standards Committee X3, on Information | ||||
| .\" Processing Systems. | .\" Processing Systems. | ||||
| .\" | .\" | ||||
| .\" Redistribution and use in source and binary forms, with or without | .\" Redistribution and use in source and binary forms, with or without | ||||
| .\" modification, are permitted provided that the following conditions | .\" modification, are permitted provided that the following conditions | ||||
| .\" are met: | .\" are met: | ||||
| Show All 13 Lines | |||||
| .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||
| .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||||
| .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||||
| .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
| .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
| .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
| .\" SUCH DAMAGE. | .\" SUCH DAMAGE. | ||||
| .\" | .\" | ||||
| .Dd April 3, 2022 | .Dd February 19, 2026 | ||||
| .Dt ABS 3 | .Dt ABS 3 | ||||
| .Os | .Os | ||||
| .Sh NAME | .Sh NAME | ||||
| .Nm abs | .Nm abs , labs , llabs , imaxabs | ||||
| .Nd integer absolute value function | .Nd return absolute value for integer types | ||||
| .Sh LIBRARY | |||||
| .Lb libc | |||||
| .Sh SYNOPSIS | .Sh SYNOPSIS | ||||
| .Lb libc | |||||
| .In stdlib.h | .In stdlib.h | ||||
| .Ft int | .Ft int | ||||
| .Fn abs "int j" | .Fn abs "int i" | ||||
| .Ft long | |||||
| .Fn labs "long i" | |||||
| .Ft long long | |||||
| .Fn llabs "long long i" | |||||
| .In inttypes.h | |||||
| .Ft intmax_t | |||||
| .Fn imaxabs "intmax_t i" | |||||
| .Sh DESCRIPTION | .Sh DESCRIPTION | ||||
| The | The | ||||
| .Fn abs | .Fn abs , | ||||
| function | .Fn labs , | ||||
| computes | .Fn llabs , | ||||
| the absolute value of the integer | and | ||||
| .Fa j . | .Fn imaxabs | ||||
| functions compute the absolute value of | |||||
| .Fa i . | |||||
| .Sh RETURN VALUES | .Sh RETURN VALUES | ||||
| The | The | ||||
| .Fn abs | .Fn abs , | ||||
| function | .Fn labs , | ||||
| returns | .Fn llabs , | ||||
| the absolute value. | and | ||||
| .Fn imaxabs | |||||
| functions return the absolute value. | |||||
| .Sh SEE ALSO | .Sh SEE ALSO | ||||
| .Xr cabs 3 , | .Xr cabs 3 , | ||||
| .Xr fabs 3 , | .Xr fabs 3 , | ||||
| .Xr floor 3 , | .Xr floor 3 , | ||||
| .Xr hypot 3 , | .Xr hypot 3 | ||||
| .Xr imaxabs 3 , | |||||
| .Xr labs 3 , | |||||
| .Xr llabs 3 , | |||||
| .Xr math 3 | |||||
| .Sh STANDARDS | .Sh STANDARDS | ||||
| The | The | ||||
| .Fn abs | .Fn abs , | ||||
| function conforms to | .Fn labs , | ||||
| .St -isoC-99 . | .Fn llabs , | ||||
| and | |||||
| .Fn imaxabs | |||||
| functions conform to | |||||
| .St -isoC-2023 | |||||
| and | |||||
| .St -p1003.1-2024 . | |||||
| .Sh HISTORY | .Sh HISTORY | ||||
| The | The | ||||
| .Fn abs | .Fn abs | ||||
| function first appeared in | function first appeared in | ||||
| .At v6 . | .At v6 . | ||||
| The | |||||
des: Missing: `labs()` first appeared in `.Bx 4.3`. | |||||
| .Fn llabs | |||||
| and | |||||
| .Fn imaxabs | |||||
| functions first appeared in | |||||
| .Fx 5.0 . | |||||
| .Sh BUGS | .Sh BUGS | ||||
| The absolute value of the most negative integer remains negative. | The absolute value of the most negative integer remains negative. | ||||
Missing: labs() first appeared in .Bx 4.3.