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

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

imaxdiv

Syntax

 
#include <inttypes.h>

imaxdiv_t imaxdiv (intmax_t numerator, intmax_t denominator);

Description

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

 
typedef struct {
  intmax_t quot;
  intmax_t rem;
} imaxdiv_t;

Return Value

The results of the division are returned.

Portability

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

Example

 
imaxdiv_t l = imaxdiv(42, 3);
printf("42 = %" PRIdMAX " x 3 + %" PRIdMAX "\n", l.quot, l.rem);

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


  webmaster     delorie software   privacy  
  Copyright © 2004     Updated Apr 2004