-1

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?

Rafael Winterhalter
  • 42,759
  • 13
  • 108
  • 192
kakush
  • 3,334
  • 14
  • 47
  • 68

2 Answers2

0

unsigned long long is 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).

Community
  • 1
  • 1
Rowland Shaw
  • 37,700
  • 14
  • 97
  • 166
0

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:

Big numbers library in c++

Community
  • 1
  • 1
univise
  • 509
  • 2
  • 11