I'm saving seconds since epoch in an unsigned long long type. how can I know what is the latest date I can get? And is there another type (besides unsigned long long) what allows me to express an even later date?
Converting epoch time to date format
125 Views Asked by kakush At
2
There are 2 best solutions below
0
On
I will assume you mean the C++ language
An unsigned long long will be at least 8 bytes (= 64 bits) large. So the range is from 0 to 2^64. You simply need to determine the date of 2^64; the underlying operating system should provide you with enough to do that.
For your second question - let me answer it like this: You can get a type to store an 'infinite' amount of bytes; 'infinite' means as much memory as available to you. Such a type would be like the BigInteger type from Java. Here is a question that addresses exactly that issue:
unsigned long longis only guaranteed to be at least 64 bit, so your maximum end date is at least 2^64 seconds after the start of your epoch (approx, 2.13503982E14 days).