delorie.com/djgpp/doc/libc/libc_134.html   search  
libc.a reference

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

div

Syntax

 
#include <stdlib.h>

div_t div(int numerator, int denominator);

Description

Returns the quotient and remainder of the division numerator divided by denominator. The return type is as follows:

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

Return Value

The results of the division are returned.

Portability

ANSI/ISO C C89; C99
POSIX 1003.2-1992; 1003.1-2001

Example

 
div_t d = div(42, 3);
printf("42 = %d x 3 + %d\n", d.quot, d.rem);

div(+40, +3) = { +13, +1 }
div(+40, -3) = { -13, +1 }
div(-40, +3) = { -13, -1 }
div(-40, -3) = { +13, -1 }


  webmaster     delorie software   privacy  
  Copyright © 2004     Updated Apr 2004