Reputation: 129
What is the size of the time variable that are used to show datetime in bits ? Actually in time.h file the time variable that are used, are they store into int variable or what ?
Upvotes: 2
Views: 4975
Reputation: 11268
From the C99 standard (7.23.1):
"The range and precision of times representable in clock_t and time_t are
implementation-defined."
From the standard's perspective it might be an integer, floating point number, Huffman encoded , etc. In practice on most UNIX-like systems it will be a 32 or 64 bit unsigned integer signifing the number of seconds since the UNIX epoch (midnight Januari 1 1970).
Upvotes: 2
Reputation: 6317
Use sizeof( time_t );
to determine the size in bytes. Then multiply this number with bits per byte (usually 8, but depends on your HW).
Upvotes: 2
Reputation: 118620
On GCC (echo '#include <time.h>' | gcc -E -
):
__extension__ typedef long int __time_t;
typedef __time_t time_t;
Platform details:
Linux stanley 2.6.32-24-generic-pae #39-Ubuntu SMP Wed Jul 28 07:39:26 UTC 2010 i686 GNU/Linux
Upvotes: 2