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

製品コード
SW006021-1
ページ / 518
MPLAB
®
 XC8 C Compiler User’s Guide
DS52053B-page 356
 2012 Microchip Technology Inc.
Example
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
void 
main (void)
{
    time_t toc;
    int i;
    time(&toc);
    srand((int)toc);
    for(i = 0 ; i != 10 ; i++)
        printf("%d\t", rand());
    putchar(’\n’);
}
See Also
srand()
Note
The example will require the user to provide the time() routine as one cannot be 
supplied with the compiler. See time() for more detail.
ROUND 
Synopsis
#include <math.h>
 
double round (double x)
Description
The 
round
 function round the argument to the nearest integer value, but in 
floating-point format. Values midway between integer values are rounded up.
Example
#include <math.h>
void 
main (void)
{
    double input, rounded;
    input = 1234.5678;
    rounded = round(input);
}
See Also
trunc()