data_types.c
changeset 0 af501b0c1716
child 8 96d16dfe787a
equal deleted inserted replaced
-1:000000000000 0:af501b0c1716
       
     1 /**
       
     2  *     $Id: data_types.c,v 1.1.1.1 2008-04-28 17:32:53 mbroeker Exp $
       
     3  * $Source: /development/c/demos/data_types.c,v $
       
     4  *
       
     5  */
       
     6 
       
     7 #include <stdio.h>
       
     8 #include <stdlib.h>
       
     9 #include <math.h>
       
    10 #include <limits.h>
       
    11 #include <float.h>
       
    12 
       
    13 typedef unsigned char UCHAR;
       
    14 typedef signed char SCHAR;
       
    15 
       
    16 typedef unsigned short USHORT;
       
    17 typedef signed short SSHORT;
       
    18 
       
    19 typedef unsigned int UINT;
       
    20 typedef signed int SINT;
       
    21 
       
    22 typedef unsigned long ULONG;
       
    23 typedef signed long SLONG;
       
    24 
       
    25 #ifdef __USE_ISOC99
       
    26 typedef unsigned long long ULLONG;
       
    27 typedef signed long long SLLONG;
       
    28 #endif
       
    29 
       
    30 int main (int argc, char **argv)
       
    31 {
       
    32     printf ("%20s %4s %20s %25s\n\n", "Type", "BITS", "MIN", "MAX");
       
    33 
       
    34     printf ("%20s %4d %20d %25d\n", "   signed char", 8 * sizeof (SCHAR), CHAR_MIN, CHAR_MAX);
       
    35     printf ("%20s %4d %20d %25d\n", "  signed short", 8 * sizeof (SSHORT), SHRT_MIN, SHRT_MAX);
       
    36     printf ("%20s %4d %20d %25d\n", "    signed int", 8 * sizeof (SINT), INT_MIN, INT_MAX);
       
    37     printf ("%20s %4d %20ld %25ld\n", "   signed long", 8 * sizeof (SLONG), LONG_MIN, LONG_MAX);
       
    38 
       
    39 #ifdef __USE_ISOC99
       
    40     printf ("%20s %4d %20lld %25lld\n\n", "  signed llong", 8 * sizeof (SLLONG), (SLLONG) LLONG_MIN, LLONG_MAX);
       
    41 #endif
       
    42 
       
    43     printf ("%20s %4d %20d %25u\n", " unsigned char", 8 * sizeof (UCHAR), 0, UCHAR_MAX);
       
    44     printf ("%20s %4d %20d %25u\n", "unsigned short", 8 * sizeof (USHORT), 0, USHRT_MAX);
       
    45 
       
    46     printf ("%20s %4d %20d %25u\n", "  unsigned int", 8 * sizeof (UINT), 0, UINT_MAX);
       
    47     printf ("%20s %4d %20lu %25lu\n", " unsigned long", 8 * sizeof (ULONG), 0UL, ULONG_MAX);
       
    48 
       
    49 #ifdef __USE_ISOC99
       
    50     printf ("%20s %4d %20llu %25llu\n", "unsigned llong", 8 * sizeof (ULLONG), 0ULL, ULLONG_MAX);
       
    51 #endif
       
    52 
       
    53 #ifdef __USE_ISOC99
       
    54     printf ("\n%20s %4d %20d  %20d\n", "_Bool", 8 * sizeof (_Bool), 0, 1);
       
    55 #endif
       
    56 
       
    57     printf ("\n%20s %4d \t\t %#1.2g \t\t %#1.2g\n", "float", 8 * sizeof (float), (double)FLT_MIN, (double)FLT_MAX);
       
    58     printf ("%20s %4d \t\t %#1.2g \t\t %#1.2g\n", "double", 8 * sizeof (double), (double)DBL_MIN, (double)DBL_MAX);
       
    59 
       
    60     return 0;
       
    61 }