Microchip Technology XC8 Standard Compiler (Workstation) SW006021-1 SW006021-1 ユーザーズマニュアル

製品コード
SW006021-1
ページ / 518
MPLAB
®
 XC8 C Compiler User’s Guide
DS52053B-page 330
 2012 Microchip Technology Inc.
Example
#include <xc.h> 
long count;
void 
interrupt tick (void) 
{
    count++;
}
long 
getticks (void)
{
    long val;    /* Disable interrupts around access
                    to count, to ensure consistency.*/
    di();
    val = count;
    ei();
    return val;
}
DIV 
Synopsis
#include <stdlib.h>
 
div_t div (int numer, int denom)
Description
The 
div()
 function computes the quotient and remainder of the numerator divided by 
the denominator.
Example
#include <stdlib.h>
#include <stdio.h>
void 
main (void)
{
    div_t x;
    x = div(12345, 66);
    printf(“quotient = %d, remainder = %d\n”, x.quot, x.rem);
}
See Also
udiv()
, ldiv(), uldiv()
Return Value
Returns the quotient and remainder into the 
div_t
 structure.
EEPROM ROUTINES 
Description
These functions are now supplied in the peripheral library. See the peripheral library 
documentation for full information on this library function.