SW006014 Microchip Technology, SW006014 Datasheet - Page 107

C COMPILER MPLAB FOR PIC24 MCU

SW006014

Manufacturer Part Number
SW006014
Description
C COMPILER MPLAB FOR PIC24 MCU
Manufacturer
Microchip Technology
Type
MPLAB® C Compilerr
Series
PIC24r
Datasheet

Specifications of SW006014

Supported Families
PIC24
Core Architecture
PIC
Kit Contents
Software And Docs
Mcu Supported Families
PIC24
Tool Function
Compiler
Tool Type
Compiler
Processor Series
PIC24
Lead Free Status / RoHS Status
Not applicable / Not applicable
For Use With/related Products
PIC24
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
© 2008 Microchip Technology Inc.
ldiv
Description:
Include:
Prototype:
Arguments:
Return Value:
Remarks:
Example:
Calculates the quotient and remainder of two long integers.
<stdlib.h>
ldiv_t ldiv(long numer, long denom);
numer
denom
Returns the quotient and the remainder.
The returned quotient will have the same sign as the numerator divided
by the denominator. The sign for the remainder will be such that the
quotient times the denominator plus the remainder will equal the
numerator (quot * denom + rem = numer). If the denominator is zero,
the behavior is undefined.
#include <stdlib.h> /* for ldiv, ldiv_t */
#include <stdio.h>
int main(void)
{
}
long x,y;
ldiv_t z;
x = 7;
y = 3;
printf("For ldiv(%ld, %ld)\n", x, y);
z = ldiv(x, y);
printf("The quotient is %ld and the "
x = 7;
y = -3;
printf("For ldiv(%ld, %ld)\n", x, y);
z = ldiv(x, y);
printf("The quotient is %ld and the "
x = -5;
y = 3;
printf("For ldiv(%ld, %ld)\n", x, y);
z = ldiv(x, y);
printf("The quotient is %ld and the "
x = 7;
y = 7;
printf("For ldiv(%ld, %ld)\n", x, y);
z = ldiv(x, y);
printf("The quotient is %ld and the "
x = 7;
y = 0;
printf("For ldiv(%ld, %ld)\n", x, y);
z = ldiv(x, y);
printf("The quotient is %ld and the "
"remainder is %ld\n\n", z.quot, z.rem);
"remainder is %ld\n\n", z.quot, z.rem);
"remainder is %ld\n\n", z.quot, z.rem);
"remainder is %ld\n\n", z.quot, z.rem);
"remainder is %ld\n\n",
z.quot, z.rem);
numerator
denominator
/* for printf
DS51456E-page 103
*/

Related parts for SW006014