Signup
Search Linux manpages For:  

ldiv(3) -- Linux man page

 

NAME

div, ldiv, lldiv, imaxdiv - compute quotient and remainder of an integer division  

SYNOPSIS

#include <stdlib.h>

div_t div(int numerator, int denominator);

ldiv_t ldiv(long numerator, long denominator);
lldiv_t lldiv(long long numerator, long long denominator); #include <inttypes.h> imaxdiv_t imaxdiv(intmax_t numerator, intmax_t denominator);
 

DESCRIPTION

The div() function computes the value numerator/denominator and returns the quotient and remainder in a structure named div_t that contains two integer members (in unspecified order) named quot and rem. The quotient is rounded towards zero. The result satisfies quot*denominator+rem = numerator.

The ldiv() and lldiv() and imaxdiv() functions do the same, dividing numbers of the indicated type and returning the result in a structure of the indicated name, in all cases with fields quot and rem of the same type as the function arguments.  

RETURN VALUE

The div_t (etc.) structure.  

EXAMPLE

After
        div_t q = div(-5, 3);
the values q.quot and q.rem are -1 and -2, respectively.  

CONFORMING TO

SVID 3, BSD 4.3, ISO 9899. The functions lldiv() and imaxdiv() were added in ISO C99.  

SEE ALSO

abs(3)


 
LINUX MAN PAGES
Man1 -- User Commands (Intro)
Man2 -- System Calls (Intro)
Man3 -- Library Functions (Intro)
Man4 -- Special Files (Intro)
Man5 -- File Formats (Intro)
Man6 -- Games (Intro)
Man7 -- Miscellaneous (Intro)
Man8 -- Administration (Intro)
Mann -- TCL Functions (not available)


WEB HOSTING SHOWCASE




 
Cheap Web HostingBudget Web HostingEcommerce Web Hosting
Link to UsLink ExchangeAdvertisePrivacy PolicyTerms Of ServiceAbout UsContact UsSitemap
Copyright © 2006 - 2012 Broadband Media, Inc. All rights reserved.