First of all, a uint64_t
is not inherently hexadecimal, octal, nor decimal: It is simply a value. Unless, perhaps, there is some other encoding of its 64-bit value?
The range of uint64_t
cannot exceed the range of a double
, but there could well be some loss of precision during the conversion. This stems from the internal representation of a double which uses a total of 64 bits: 1 bit for the sign, 11 for the exponent, and 53-54 for the mantissa. In contrast, a uint64_t
uses 64 bits for the value.
Nearby timestamps are likely to have the same double
value. So subtracting one from the other would provide a difference as uint64, but zero as a double.
The usual method to convert from one to the other in c works great in c++ too:
uint64_t val64 = 892749724729742uL;
double d = val64;