|
CC78K4 Datasheet, PDF (206/523 Pages) NEC – CC78K4 Ver.2.30 or Later, C Compiler Language | |||
|
◁ |
CHAPTER 10 LIBRARY FUNCTIONS
5-10 div,
ldiv
Utility Functions
FUNCTION
The mathematical function div performs the integer division of numerator divided by denominator.
The mathematical function ldiv performs the long integer division of numerator divided by denominator.
HEADER
stdlib.h
FUNCTION PROTOTYPE
div_t div (int numer, int denom);
ldiv_t ldiv (long int numer, long int denom);
Function
div
ldiv
Arguments
numer ... Numerator of the
division
denom ... Denominator of the
division
Return Value
Quotient to the quot element
of structure type
div_t and the remainder to the
rem element
Quotient to the quot element
of structure type
ldiv_t and the remainder to
the rem element
EXPLANATION
div
⢠The div function performs the integer division of numerator divided by denominator. The result of div has a
structure type named div_t with the elements quo (quotient) and rem (remainder).
⢠The absolute value of the quotient is defined as the largest integer not greater than the absolute value of
numer divided by the absolute value of denom. The remainder always has the same sign as the result of the
division (plus if numer and denom have the same sign; otherwise minus).
⢠The remainder is the value of numer - denom*quotient.
If denom is 0, the quotient becomes 0 and the remainder becomes numer. If numer is â32768 and denom
is â1, the quotient becomes â32768 and the remainder becomes 0.
ldiv
⢠The ldiv function performs the long integer division of numerator divided by denominator. The result of ldiv
has a structure type named âldiv_tâ with the elements quo (quotient) and rem (remainder).
⢠The absolute value of the quotient is defined as the largest long int type integer not greater than the absolute
value of numer divided by the absolute value of denom. The remainder always has the same sign as the
result of the division (plus if numer and denom have the same sign; otherwise minus).
⢠The remainder is the value of numer - denom*quotient.
If denom is 0, the quotient becomes 0 and the remainder becomes numer. If numer is â2147483648 and
denom is â1, the quotient becomes â2147483648 and the remainder becomes 0.
206
Userâs Manual U15556EJ1V0UM
|
▷ |