|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
Re: max file size (again)...
From: Cami (camis
mweb.co.za)
Date: Tue Sep 02 2003 - 02:06:53 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
| > #include <sys/types.h>
| > #include <limits.h>
| > #include <stdio.h>
| >
| > #define MAXINT(T) ((T) (((T)1 << ((sizeof(T) * CHAR_BIT) - 1) ^ ((T)
| > -1))))
| >
| > main()
| > {
| > printf("%d\n", MAXINT(char));
| > printf("%d\n", MAXINT(short));
| > printf("%d\n", MAXINT(int));
| > printf("%ld\n", MAXINT(long));
| > printf("%lld\n", MAXINT(off_t));
| > }
| >
| > On my I386 box the output from this test program is:
| >
| > 127
| > 32767
| > 2147483647
| > 2147483647
| > 9223372036854775807
| >
| > When changed to print hexadecimal output:
| >
| > #include <sys/types.h>
| > #include <limits.h>
| > #include <stdio.h>
| >
| > #define MAXINT(T) ((T) (((T)1 << ((sizeof(T) * CHAR_BIT) - 1) ^ ((T)
| > -1))))
| >
| > main()
| > {
| > printf("0x%x\n", MAXINT(char));
| > printf("0x%x\n", MAXINT(short));
| > printf("0x%x\n", MAXINT(int));
| > printf("0x%lx\n", MAXINT(long));
| > printf("0x%llx\n", MAXINT(off_t));
| > }
| >
| > Output becomes:
| >
| > 0x7f
| > 0x7fff
| > 0x7fffffff
| > 0x7fffffff
| > 0x7fffffffffffffff
| >
| > It would be nice to hear how this works on 64-bit systems. I can
| > try this on SPARC/Solaris myself.
Linux goliath 2.4.21-sparc-r1 #6 Tue Aug 12 16:07:56 SAST 2003 sparc64 sun4u TI UltraSparc IIe GNU/Linux
0x7f
0x7fff
0x7fffffff
0x7fffffff
0x7fffffff00010480
SunOS ultra 5.9 Generic_112233-05 sun4u sparc SUNW,Ultra-1
0x7f
0x7fff
0x7fffffff
0x7fffffff
0x7fffffff0003283c
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]