www.delorie.com/djgpp/doc/libc-2.01/libc_438.html   search  
Go to the first, previous, next, last section, table of contents.


ldiv

Syntax

#include <stdlib.h>

ldiv_t ldiv(long numerator, long denomonator);

Description

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

typedef struct {
  long quot;
  long rem;
} ldiv_t;

Return Value

The results of the division are returned.

Example

ldiv_t l = ldiv(42, 3);
printf("42 = %ld x 3 + %ld\n", l.quot, l.rem);

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


Go to the first, previous, next, last section, table of contents.

  prev next   webmaster     delorie software   privacy  
  Copyright © 1997     Updated Apr 1997