Contiki 2.5
test_printf.c
1 
2 int main (){
3 double f;
4 
5 /*double f4;
6 long double f1;
7 float f2, f3;
8 float flottant;*/
9 
10  f = 48656568.256479123456789123456789;
11 /*
12 f1= 48656568.256479123456789123456789;
13 f2 = 456.45366;
14 f3 = 456.45362; */
15 //printf("Test du printf");
16 
17 /*Simple test of %f format */
18 printf("double :%lf\n",f);
19 
20 /* Test with format specifying first number is equal to minimal number
21  of caracter to be print the second one is number of digits */
22 /*
23 printf("LONG DOUBLE :%Lf - %20.10Lf - %20.15Lf - %20.20Lf - %30.30Lf\n", f1, f1, f1, f1, f1);
24 printf("float2 :%4.2f %+.0e %E \n", 3.1416, 3.1416, 3.1416);*/
25 
26 /*Note: the output should be float2: 3.14 +3e+000 3.141600E+000*/
27 /*
28 printf("float3 :%7.3f\n", 1.2345);
29 printf("float3bis :%7.3lf\n",4865.256479 );
30 printf("float4 :%10.3f\n", 1.2345e3);
31 printf("float5 :%10.3f\n", 1.2345e7);
32 printf("float6 :%12.4e\n", 1.2345);
33 printf("float7 :%12.4e\n", 123.456789e8);
34 printf("float8 :%15.5lf\n",48656568.256479 );
35 printf("float9 :%15.6lf\n",48656568.256479 - 48656568.256478 );
36 printf("float9bis :%15.2lf\n",f2*f3 );*/
37 /*Note : the outputs shoud be
38 for 1.2345, ^^1.235
39 for 1.2345e5, ^^1234.500
40 for 1.2345e7, 12345000.000
41 for 1.2345, ^^1.2345e+00
42 for 123.456789e8, ^^1.2346e+10
43 for 48656568.256479 - 48656568.2563,^^^^^^^^0.00001
44 for f2*f3 ,^^^^^^208349,92
45 ^ is equal to a space */
46 
47 /*
48 printf("float10 :01234567 \n" );
49 printf("float11 :%8g|\n", 12.34 );
50 printf("float12 :%8g|\n", 1234.5678 );
51 printf("float13 :%8g|\n", 0.0478 );
52 printf("float14 :%8g|\n", 422121.0 );
53 printf("float15 :%8g|\n", 422121234.345345 );*/
54 /*Note : outputs should be
55 01234567
56  12.34|
57  1234.57|
58  0.0478|
59  422121|
60 4.22121e+08|
61 */
62 /*
63 
64 printf("float16 :%.0f|\n", 1000.123456789123456789 );
65 printf("float17 :%.1f|\n", 2000.123456789123456789 );
66 printf("float18 :%.2f|\n", 3000.123456789123456789 );
67 printf("float19 :%.10f|\n", 4000.123456789123456789 );
68 printf("float20 :%.30f|\n", 5000.123456789123456789 );
69 printf("float21 :%f|\n", 6000.123456789123456789 );
70 printf("float22 :%.f|\n", 7000.123456789123456789 );
71 */
72 /*Note : outputs should be
73 1000|
74 2000.1|
75 3000.12|
76 4000.1234567891|
77 5000.12345678912333823973312939761|
78 6000.123457|
79 7000|
80 */
81 
82 
83 //while(1);
84 
85 }
86 
87