I changed this to make the output easier to read. If some 64-bit folks
could run it and post the output, I would appreciate it.
# include <stdio.h>
# include <stddef.h>
int
main (void)
{
ptrdiff_t last, next;
printf ("\n");
printf (" last");
printf (" next");
printf (" double");
printf ("\n\n");
for (last = 32767; (next = 2 * (double) last + 1) > last
{
printf ("%22lld %22lld %32f\n", (long long) last, (long long) next,
2 * (double) last + 1);
last = next;
}
printf ("\n%22lld\n%22llx\n\n", (long long) last, (long long) last);
return 0;
}
I don't know why you're fooling around with this but here you go.
It seems to me that INT_MAX/INT_MIN or UINT_MAX would serve the purpose
if you don't have SIZE_MAX.
last next double
32767 65535 65535.000000
65535 131071 131071.000000
131071 262143 262143.000000
262143 524287 524287.000000
524287 1048575 1048575.000000
1048575 2097151 2097151.000000
2097151 4194303 4194303.000000
4194303 8388607 8388607.000000
8388607 16777215 16777215.000000
16777215 33554431 33554431.000000
33554431 67108863 67108863.000000
67108863 134217727 134217727.000000
134217727 268435455 268435455.000000
268435455 536870911 536870911.000000
536870911 1073741823 1073741823.000000
1073741823 2147483647 2147483647.000000
2147483647 4294967295 4294967295.000000
4294967295 8589934591 8589934591.000000
8589934591 17179869183 17179869183.000000
17179869183 34359738367 34359738367.000000
34359738367 68719476735 68719476735.000000
68719476735 137438953471 137438953471.000000
137438953471 274877906943 274877906943.000000
274877906943 549755813887 549755813887.000000
549755813887 1099511627775 1099511627775.000000
1099511627775 2199023255551 2199023255551.000000
2199023255551 4398046511103 4398046511103.000000
4398046511103 8796093022207 8796093022207.000000
8796093022207 17592186044415 17592186044415.000000
17592186044415 35184372088831 35184372088831.000000
35184372088831 70368744177663 70368744177663.000000
70368744177663 140737488355327 140737488355327.000000
140737488355327 281474976710655 281474976710655.000000
281474976710655 562949953421311 562949953421311.000000
562949953421311 1125899906842623 1125899906842623.000000
1125899906842623 2251799813685247 2251799813685247.000000
2251799813685247 4503599627370495 4503599627370495.000000
4503599627370495 9007199254740991 9007199254740991.000000
9007199254740991 18014398509481984 18014398509481984.000000
18014398509481984 36028797018963968 36028797018963968.000000
36028797018963968 72057594037927936 72057594037927936.000000
72057594037927936 144115188075855872 144115188075855870.000000
144115188075855872 288230376151711744 288230376151711740.000000
288230376151711744 576460752303423488 576460752303423490.000000
576460752303423488 1152921504606846976 1152921504606847000.000000
1152921504606846976 2305843009213693952 2305843009213694000.000000
2305843009213693952 4611686018427387904 4611686018427387900.000000
4611686018427387904
4000000000000000