diff options
author | sinanmohd <pcmsinan@gmail.com> | 2022-06-04 12:11:15 +0530 |
---|---|---|
committer | sinanmohd <pcmsinan@gmail.com> | 2022-06-04 12:11:15 +0530 |
commit | c24973af02bc33f2f5f25d37e22ca91da5de3c47 (patch) | |
tree | 460a005b6a3a9a967bd881bc2bf01e0becbe33cc /2.1.c |
inital commit
Diffstat (limited to '2.1.c')
-rw-r--r-- | 2.1.c | 55 |
1 files changed, 55 insertions, 0 deletions
@@ -0,0 +1,55 @@ +#include <stdio.h> +#include <limits.h> +#include <float.h> + +int +main(void) +{ + unsigned char c; + unsigned short s; + unsigned int i; + unsigned long l; + + c = ~0; + s = ~0; + i = ~0; + l = ~0; + + c >>= 1; + s >>= 1; + i >>= 1; + l >>= 1; + + /* signed values */ + + printf("limits char min: %20d, max: %20d\n", CHAR_MIN, CHAR_MAX); + printf("comput char min: %20d, max: %20d\n", -c-1, c); + + printf("limits short min: %20d, max: %20d\n", SHRT_MIN, SHRT_MAX); + printf("comput short min: %20d, max: %20d\n", -s-1, s); + + printf("limits int min: %20d, max: %20d\n", INT_MIN, INT_MAX); + printf("comput int min: %20d, max: %20d\n", -i-1, i); + + printf("limits long min: %20ld, max: %20ld\n", LONG_MIN, LONG_MAX); + printf("comput long min: %20ld, max: %20ld\n", -l-1, l); + + printf("limits float min: %20g, max: %20g\n", FLT_MIN, FLT_MAX); + printf("limits double min: %20g, max: %20g\n", DBL_MIN, DBL_MAX); + + /* unsigned values */ + + printf("limits uchar min: %20d, max: %20u\n", 0, UCHAR_MAX); + printf("comput uchar min: %20d, max: %20u\n", 0, c*2+1); + + printf("limits ushort min: %20d, max: %20u\n", 0, USHRT_MAX); + printf("comput ushort min: %20d, max: %20u\n", 0, s*2+1); + + printf("limits uint min: %20d, max: %20u\n", 0, UINT_MAX); + printf("comput uint min: %20d, max: %20u\n", 0, i*2+1); + + printf("limits ulong min: %20d, max: %20lu\n", 0, ULONG_MAX); + printf("comput ulong min: %20d, max: %20lu\n", 0, l*2+1); + + return 0; +} |