OAR

RTEMS GNU Tools On-Line Library


div

PREV UP NEXT Bookshelf

1.9: div---divide two integers

Synopsis

#include <stdlib.h>
div_t div(int n, int d);

Description
Divide n/d, returning quotient and remainder as two integers in a structure div_t.


Returns
The result is represented with the structure

 typedef struct
 {
  int quot;
  int rem;
 } div_t;

where the quot field represents the quotient, and rem the remainder. For nonzero d, if `r = div(n,d);' then n equals `r.rem + d*r.quot'.

To divide long rather than int values, use the similar function ldiv.


Portability
div is ANSI.

No supporting OS subroutines are required.



PREV UP NEXT Bookshelf

Packaging copyright © 1988-2000 OAR Corporation
Context copyright by each document's author. See Free Software Foundation for information.