| <html lang="en"> |
| <head> |
| <title>abs - Untitled</title> |
| <meta http-equiv="Content-Type" content="text/html"> |
| <meta name="description" content="Untitled"> |
| <meta name="generator" content="makeinfo 4.13"> |
| <link title="Top" rel="start" href="index.html#Top"> |
| <link rel="up" href="Stdlib.html#Stdlib" title="Stdlib"> |
| <link rel="prev" href="abort.html#abort" title="abort"> |
| <link rel="next" href="assert.html#assert" title="assert"> |
| <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> |
| <meta http-equiv="Content-Style-Type" content="text/css"> |
| <style type="text/css"><!-- |
| pre.display { font-family:inherit } |
| pre.format { font-family:inherit } |
| pre.smalldisplay { font-family:inherit; font-size:smaller } |
| pre.smallformat { font-family:inherit; font-size:smaller } |
| pre.smallexample { font-size:smaller } |
| pre.smalllisp { font-size:smaller } |
| span.sc { font-variant:small-caps } |
| span.roman { font-family:serif; font-weight:normal; } |
| span.sansserif { font-family:sans-serif; font-weight:normal; } |
| --></style> |
| </head> |
| <body> |
| <div class="node"> |
| <a name="abs"></a> |
| <p> |
| Next: <a rel="next" accesskey="n" href="assert.html#assert">assert</a>, |
| Previous: <a rel="previous" accesskey="p" href="abort.html#abort">abort</a>, |
| Up: <a rel="up" accesskey="u" href="Stdlib.html#Stdlib">Stdlib</a> |
| <hr> |
| </div> |
| |
| <h3 class="section">2.4 <code>abs</code>—integer absolute value (magnitude)</h3> |
| |
| <p><a name="index-abs-5"></a><strong>Synopsis</strong> |
| <pre class="example"> #include <stdlib.h> |
| int abs(int <var>i</var>); |
| |
| </pre> |
| <p><strong>Description</strong><br> |
| <code>abs</code> returns |
| the absolute value of <var>i</var> (also called the magnitude |
| of <var>i</var>). That is, if <var>i</var> is negative, the result is the opposite |
| of <var>i</var>, but if <var>i</var> is nonnegative the result is <var>i</var>. |
| |
| <p>The similar function <code>labs</code> uses and returns <code>long</code> rather than <code>int</code> values. |
| |
| <p><br> |
| <strong>Returns</strong><br> |
| The result is a nonnegative integer. |
| |
| <p><br> |
| <strong>Portability</strong><br> |
| <code>abs</code> is ANSI. |
| |
| <p>No supporting OS subroutines are required. |
| |
| <p><br> |
| |
| </body></html> |
| |