1 | #include <stdio.h> |
2 | #include "pico/stdlib.h" |
3 | |
4 | float x,sum ; |
5 | |
6 | void floatTest1(){ |
7 | float sum=0 ; |
8 | float x=1.0 ; |
9 | float val=1.0 ; |
10 | int time1=time_us_32() ; |
11 | for(int kk=0 ; kk<100 ; kk++){ |
12 | x=x+1.234 ; |
13 | sum=sum+1.0/(x*x)+x+val ; |
14 | val=val+0.01234+2.34/(sum*sum) ; |
15 | }
|
16 | int time2=time_us_32() ; |
17 | printf("time2-time1=%6d ",time2-time1) ; |
18 | printf("x=%10.5f sum=%10.5f val=%10.5f\n",x,sum,val) ; |
19 | |
20 | }
|
21 | |
22 | void floatTest2(){ |
23 | while(1){ |
24 | floatTest1() ; |
25 | sleep_ms(1000) ; |
26 | }
|
27 | }
|
28 | |
29 | int main(){ |
30 | stdio_init_all(); |
31 | floatTest2() ; |
32 | }
|