[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]

Computes absolute value, division, and double precision multiplication of integers.

#include <stdlib.h>

int abs (i)inti;

#include <stdlib.h>

long labs (i)longi;

#include <stdlib.h>

**div_t div (** *Numerator***,** *Denominator***)**

**int*** Numerator***:*** Denominator***;**

#include <stdlib.h>

**void imul_dbl**** (** *i***,** *j***,** Result**)**

**long*** i***,*** j***;**

**long**** ****Result***;**

#include <stdlib.h>

ldiv_t ldiv(Numerator,Denominator)longNumerator:Denominator;

#include <stdlib.h>

void umul_dbl(i,j,Result)unsigned longi,j;unsigned long *Result;

#include <stdlib.h>

long long int llabs(i)long long inti;

#include <stdlib.h>

lldiv_t lldiv (Numerator,Denominator)long long intNumerator,Denominator;

The **abs** subroutine
returns the absolute value of its integer operand.

Note:A twos-complement integer can hold a negative number whose absolute value is too large for the integer to hold. When given this largest negative value, theabssubroutine returns the same value.

The **div** subroutine
computes the quotient and remainder of the division of the number represented
by the *Numerator* parameter by that specified by the
*Denominator* parameter. If the division is inexact, the sign
of the resulting quotient is that of the algebraic quotient, and the magnitude
of the resulting quotient is the largest integer less than the magnitude of
the algebraic quotient. If the result cannot be represented (for
example, if the denominator is 0), the behavior is undefined.

The** labs** and**
ldiv** subroutines are included for compatibility with the ANSI C library,
and accept long integers as parameters, rather than as integers.

The **imul_dbl** subroutine
computes the product of two signed longs,* i* and* j,* and
stores the double long product into an array of two signed longs pointed to by
the *Result* parameter*.*

The **umul_dbl** subroutine
computes the product of two unsigned longs,* i* and* j,* and
stores the double unsigned long product into an array of two unsigned longs
pointed to by the *Result* parameter.

The **llabs** and
**lldiv** subroutines compute the absolute value and division of long
long integers. These subroutines operate under the same restrictions as
the **abs** and **div** subroutines.

Note:When given the largest negative value, thellabssubroutine (like theabssubroutine) returns the same value.

The **abs**,
**labs**, and **llabs** subroutines return the absolute
value. The **imul_dbl** and **umul_dbl** subroutines have
no return values. The **div** subroutine returns a structure of
type **div_t**. The **ldiv** subroutine returns a
structure of type** ldiv_t**, comprising the quotient and the
remainder. The structure is displayed as:

struct ldiv_t { int quot; /* quotient */ int rem; /* remainder */ };

The **lldiv** subroutine
returns a structure of type **lldiv_t**, comprising the quotient and
the remainder.
**
**