Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX 11i Version 1.5 Reference Volume 4, Section 3: Libraries > d

div(3C)

» 

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Index

NAME

div(), ldiv() — integer division and remainder

SYNOPSIS

#include <stdlib.h>

div_t div(int numer, int denom);

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

DESCRIPTION

div()

Computes the quotient and remainder of the division of the numerator numer by the denominator denom. If the division is inexact, the sign of the resulting quotient is that of the algebraic quotient, and the magnitude of the resulting quotient is the largest integer less than the magnitude of the algebraic quotient. If the result can be represented, the result is returned in a structure of type div_t (defined in <stdlib.h>) having members quot and rem for the quotient and remainder respectively. Both members have type int and values such that quot × denom + rem = numer. If the result cannot be represented, the behavior is undefined.

ldiv()

Similar to div(), except that the arguments each have type long int and the result is returned in a structure of type ldiv_t (defined in <stdlib.h>) having long int members quot and rem for the quotient and remainder respectively.

WARNINGS

Behavior is undefined if denom is zero.

STANDARDS CONFORMANCE

div(): AES, SVID3, XPG4, ANSI C

ldiv(): AES, SVID3, XPG4, ANSI C

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1983-2001 Hewlett-Packard Development Company, L.P.