A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cplusplus.com/reference/cstdlib/ldiv/ below:

function

<cstdlib>

ldiv
ldiv_t ldiv (long int numer, long int denom);

Integral division

Returns the integral quotient and remainder of the division of numer by denom ( numer/denom ) as a structure of type ldiv_t, which has two members: quot and rem.

Parameters
numer
Numerator.
denom
Denominator.

Return Value The result is returned by value in a ldiv_t structure, which has two members (in either order):
1
2
long int quot;   // quotient
long int rem;    // remainder 

Example
1
2
3
4
5
6
7
8
9
10
11
/* ldiv example */
#include <stdio.h>      /* printf */
#include <stdlib.h>     /* ldiv, ldiv_t */

int main ()
{
  ldiv_t ldivresult;
  ldivresult = ldiv (1000000L,132L);
  printf ("1000000 div 132 => %ld, remainder %ld.\n", ldivresult.quot, ldivresult.rem);
  return 0;
}

Output:
1000000 div 132 => 7575, remainder 100.


Data races Concurrently calling this function is safe, causing no data races.

Exceptions (C++)No-throw guarantee: this function throws no exceptions.

If either part of the result cannot be represented, it causes undefined behavior.



See also
div
Integral division (function)
lldiv
Integral division (function)
ldiv_t
Structure returned by ldiv (type)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4