ldiv

Calculates the quotient and remainder of the division of a number

Local Servers:nonblocking
Remote Servers:N/A
Classification:ANSI
Service:Mathematical Computation

Syntax

  #include <stdlib.h>  
   
  ldiv_t ldiv  (  
     long int   numer,   
     long int   denom);
  

Parameters

numer
(IN) Specifies the numerator.
denom
(IN) Specifies the denominator.

Return Values

This function returns a structure of type ldiv_t that contains the fields quot and rem, which are both of type long int.

Remarks

The ldiv function calculates the quotient and remainder of the division of the numerator numer by the denominator denom.

See Also

div

Example

  #include <stdlib.h>  
  #include <stdio.h>  
   
  void print_time (long int ticks);  
  {  
     ldiv_t sec_ticks;  
     ldiv_t min_sec;  
     sec_ticks = ldiv (ticks, 100L);  
     min_sec = ldiv (sec_ticks.quot, 60L);  
     printf ("It took %ld minutes and %ld seconds\n",  
        min_sec.quot, min_sec.rem);  
  }
  

produces the following:

  It took 14 minutes and 27 seconds