Something About Date Type



Hello, I want to find out how many digits does each date type have and
how many bytes does it occupy in memory, so I wrote a program below:

#include <stdio.h>
const long double num=1123222.232121342;
main()
{
Printf("the number occupies: %i, and it is 1123222.232121342
\n",sizeof num);
printf("char: %i ,the number is %c\n",sizeof(char),(char)num);
printf("widechar: %i\n",sizeof(wchar_t));
printf("singed char: %i\n",sizeof(signed char));
printf("unsigned char: %i\n",sizeof(unsigned char));
printf("int: %i, the number is %i\n",sizeof(int),(int)num);
printf("long int: %i, the number is %li\n",sizeof(long int),(long
int)num);
printf("float: %i, the number is %f\n", sizeof(float),float(num));
printf("double: %i, the number is
%lf\n",sizeof(double),(double)num);
printf("long double: %i,the number is %Lf\n",sizeof(long
double),(long double)num);
printf("long long int: %i\n",sizeof(long long int));
printf("long long double: %i\n",sizeof(long long double));
}

But the execution result of the program is very surprising:

the number occupies: 12, and it is 1123222.232121342
char: 1 ,the number is 
widechar: 2
singed char: 1
unsigned char: 1
int: 4, the number is 1123222
long int: 4, the number is 1123222
float: 4, the number is 1123222.250000
double: 8, the number is 1123222.232121
long double: 12,the number is -0.000000
long long int: 8
long long double: 8

You may notice that:
the memory occupied by int Date type and long int Date type is the
same,
print of long double number is not correct ,
and the memory long long double date type occupied is smaller (8 bytes)
than long double date type(12 bytes).
The Compiler I Use is GCC. The OS I use is Windows XP.
Can anyone tells me why do these problems happen?
Thanks a million.

.



Relevant Pages

  • Re: malloc()/realloc() - have I got this right?
    ... In one of the questions, you have to write a function to read lines of arbitrary length from the command line, using mallocand reallocto allocate the necessary memory to hold the lines. ... char *getline ... int line_len = 0; ... I'm hoping someone can tell me if I've got this function basically right - have I introduced some bug which is causing the crash, or is it a Windows thing that I don't need to concern myself with? ...
    (comp.lang.c)
  • Re: Alignment, placement new, trap representations
    ... > int i; ... placement new should be used with memory allocated on the freestore. ... This syntax also avoids the signed char issue. ... the archives for "trap representation" "signed char"). ...
    (comp.lang.cpp)
  • Re: BUG: memory where pointer pointing to changed accidently
    ... int isDir; ... void insert(TreeNodePtr *, TreeNodePtr); ... char* token; ... And thus this it will point to some memory you don't ...
    (comp.lang.c)
  • Re: Can I do ANYTHING on allocated memory?
    ... memory, can I do with it whatever I want (as in the example, use memory allocated as char *, as memory where I store integers)? ... int main{ ...
    (comp.lang.c)
  • Re: char * can point to any byte?!
    ... char* is a pointer to a char, which is the size of a byte. ... char * could point to the 2nd or 3rd byte in int? ... On some systems like x86 this is not a problem since memory is byte ... Using char* tells the compiler that you want byte access to memory. ...
    (comp.lang.c)