SW006013 Microchip Technology, SW006013 Datasheet - Page 65

MPLAB C Compiler For DsPIC DSCs

SW006013

Manufacturer Part Number
SW006013
Description
MPLAB C Compiler For DsPIC DSCs
Manufacturer
Microchip Technology
Series
DsPIC30F/33Fr
Type
MPLAB® C Compilerr
Datasheet

Specifications of SW006013

Supported Families
DsPIC30F, DsPIC33F
Core Architecture
DsPIC
Kit Contents
Software And Docs
Mcu Supported Families
DsPIC30F And DsPIC33F
Tool Function
Compiler
Tool Type
Compiler
Processor Series
dsPIC
Lead Free Status / RoHS Status
na
For Use With/related Products
dSPIC DSCs
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
© 2008 Microchip Technology Inc.
fread (Continued)
}
Output:
10.0/1 = 10.000000
10.0/2 = 5.000000
10.0/3 = 3.333333
10.0/4 = 2.500000
10.0/5 = 2.000000
10.0/6 = 1.666667
10.0/7 = 1.428571
10.0/8 = 1.250000
10.0/9 = 1.111111
10.0/10 = 1.000000
Wrote 10 numbers
Read 10 numbers
1 * 10.000000 = 10.000000
2 * 5.000000 = 10.000000
3 * 3.333333 = 10.000000
4 * 2.500000 = 10.000000
5 * 2.000000 = 10.000000
6 * 1.666667 = 10.000000
7 * 1.428571 = 10.000000
8 * 1.250000 = 10.000000
9 * 1.111111 = 10.000000
10 * 1.000000 = 10.000000
Explanation:
This program uses fwrite to save 10 numbers to a file in binary form.
This allows the numbers to be saved in the same pattern of bits as the
program is using which provides more accuracy and consistency. Using
fprintf would save the numbers as text strings which could cause
the numbers to be truncated. Each number is divided into 10 to pro-
duce a variety of numbers. Retrieving the numbers with fread to a
new array and multiplying them by the original number shows the num-
bers were not truncated in the save process.
if ((buf = fopen("afile.out", "r+")) != NULL)
{
}
else
numread = fread(readnums, sizeof(double),
printf("Read %d numbers\n", numread);
for (x = 0; x < 10; x++)
{
}
fclose(buf);
printf("Cannot open afile.out\n");
printf("%d * %f = %f\n", x+1, readnums[x],
(x + 1) * readnums[x]);
10, buf);
DS51456E-page 61

Related parts for SW006013