oga's tools
Revision | 48d55cbdb48f78f255e09d3e4a1113623b9a584b (tree) |
---|---|
Zeit | 2014-01-01 05:52:30 |
Autor | oga <oga@mxg....> |
Commiter | oga |
2014/01/01 fix win prob.
@@ -2,6 +2,7 @@ | ||
2 | 2 | * rand : ランダムテスト |
3 | 3 | * |
4 | 4 | * 2006/05/14 V0.10 by oga. |
5 | + * 2014/01:01 V0.11 fix win prob. | |
5 | 6 | */ |
6 | 7 | |
7 | 8 | #ifdef _WIN32 |
@@ -45,8 +46,9 @@ int main(int a, char *b[]) | ||
45 | 46 | } |
46 | 47 | |
47 | 48 | #ifndef _WIN32 |
48 | - /* Windowsではいまいち */ | |
49 | + /* Windowsではイマイチ */ | |
49 | 50 | tt = time(0); |
51 | + | |
50 | 52 | #else /* _WIN32 */ |
51 | 53 | GetLocalTime(&syst); |
52 | 54 | tt = syst.wHour * 3600 * 1000 + |
@@ -54,9 +56,18 @@ int main(int a, char *b[]) | ||
54 | 56 | syst.wSecond * 1000 + |
55 | 57 | syst.wMilliseconds; |
56 | 58 | #endif /* _WIN32 */ |
59 | + | |
57 | 60 | srand(tt); |
58 | 61 | |
59 | - printf("tt:%d RAND(%d):%d\n", tt, max, RAND(max)); | |
62 | + if (sizeof(time_t) == sizeof(int)) { | |
63 | + printf("tt:%d RAND(%d):%d\n", tt, max, RAND(max)); | |
64 | + } else { | |
65 | +#ifdef _WIN32 | |
66 | + printf("tt:%I64u RAND(%d):%d\n", tt, max, RAND(max)); | |
67 | +#else | |
68 | + printf("tt:%llu RAND(%d):%d\n", tt, max, RAND(max)); | |
69 | +#endif | |
70 | + } | |
60 | 71 | |
61 | 72 | return 0; |
62 | 73 | } |