ich wollte messen wie lange t braucht bis zum overflow. aber wenn ich
das Nötige
// end = clock();
einkommentiere stürtzt das programm ab. jemand ne idee wieso?
1 | #include <stdio.h>
|
2 | #include <stdlib.h>
|
3 | #include <stdint.h>
|
4 | #include <limits.h>
|
5 | #include <time.h>
|
6 |
|
7 |
|
8 | int t=0,s=0;
|
9 | clock_t start, end;
|
10 | double cpu_time_used;
|
11 |
|
12 | int main(void)
|
13 | {
|
14 | printf("size of int: %d bits\n",sizeof(t)*8);
|
15 | printf("The maximum value of INT = %d\n", INT_MAX);
|
16 | while(1) {
|
17 | t++;
|
18 | if(t<0) {
|
19 | end = clock();
|
20 | s++;
|
21 | t=0;
|
22 | printf("overflow: %i\n",s);
|
23 | cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC;
|
24 | printf("cpu time used: %i\n",cpu_time_used);
|
25 | start = clock();
|
26 | }
|
27 | }
|
28 |
|
29 | return 0;
|
30 | }
|
EDIT:
1 Fehler gefunden:
Ach misst, natürlich gehört die zeile
// end = clock();
ins if(..)
aber trotzdem ist die Zeitmessung falsch. mal ne positive zeit, beim
Nächsten Programmstart ne negative ...