Daniel Peter
/
IntegerTypes
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 // http://home.att.net/~jackklein/c/inttypes.html 00002 00003 #include "mbed.h" 00004 #include "limits.h" 00005 00006 volatile int char_min = CHAR_MIN; 00007 00008 int main() { 00009 00010 printf("Size of Boolean type is %d byte(s)\n\n", 00011 (int)sizeof(_Bool)); 00012 00013 printf("Number of bits in a character: %d\n", 00014 CHAR_BIT); 00015 printf("Size of character types is %d byte\n", 00016 (int)sizeof(char)); 00017 printf("Signed char min: %d max: %d\n", 00018 SCHAR_MIN, SCHAR_MAX); 00019 printf("Unsigned char min: 0 max: %u\n", 00020 (unsigned int)UCHAR_MAX); 00021 00022 printf("Default char is "); 00023 if (char_min < 0) 00024 printf("signed\n\n"); 00025 else if (char_min == 0) 00026 printf("unsigned\n\n"); 00027 else 00028 printf("non-standard\n\n"); 00029 00030 printf("Size of short int types is %d bytes\n", 00031 (int)sizeof(short)); 00032 printf("Signed short min: %d max: %d\n", 00033 SHRT_MIN, SHRT_MAX); 00034 printf("Unsigned short min: 0 max: %u\n\n", 00035 (unsigned int)USHRT_MAX); 00036 00037 printf("Size of int types is %d bytes\n", 00038 (int)sizeof(int)); 00039 printf("Signed int min: %d max: %d\n", 00040 INT_MIN, INT_MAX); 00041 printf("Unsigned int min: 0 max: %u\n\n", 00042 (unsigned int)UINT_MAX); 00043 00044 printf("Size of long int types is %d bytes\n", 00045 (int)sizeof(long)); 00046 printf("Signed long min: %ld max: %ld\n", 00047 LONG_MIN, LONG_MAX); 00048 printf("Unsigned long min: 0 max: %lu\n\n", 00049 ULONG_MAX); 00050 00051 printf("Size of long long types is %d bytes\n", 00052 (int)sizeof(long long)); 00053 printf("Signed long long min: %lld max: %lld\n", 00054 LLONG_MIN, LLONG_MAX); 00055 printf("Unsigned long long min: 0 max: %llu\n", 00056 ULLONG_MAX); 00057 00058 printf("Size of float types is %d bytes\n", 00059 (int)sizeof(float)); 00060 printf("Size of double types is %d bytes\n", 00061 (int)sizeof(double)); 00062 printf("Size of long double types is %d bytes\n", 00063 (int)sizeof(long double)); 00064 00065 }
Generated on Thu Jul 14 2022 06:23:15 by 1.7.2