I am reading a paradox file with the .DB extension. I have successfully read header and records but I have some problem on the Timestamp type. Timestamp take 8 bytes and are formatted like this:
Float field where the integer portion is the number of days since Jan 1, 0001 and the fractional part is the time -- expressed as a proportion of the day. For example, 6:00 PM would be .75 since it is 3/4 of the day past midnight.
I have already read Date type (number of days since Jan 1, 0001). And I know the two following :
1 10000101100 1100111100010110100010001100111000010010101010000000 > 14/11/2017 09:05:18
1 10000101100 1100111010011000001111011111111100101100000000000000 > 21/09/2015 15:01:39
I have the following code:
#include <math.h>
#include <cmath>
union Converter { uint64_t i; double d; };
std::bitset<64> timestamp(0);
double intpart, fractpart;
for (int i = 0; i<end-start; i++) {
timestamp <<= 8;
timestamp ^= (unsigned char)(buffer[start+i]);
}
fractpart = modf(convert(timestamp.to_ullong()),&intpart);
unsigned long int test = (unsigned long int)intpart;
std::cout<<test;
Which returns 786841003 for the integer portion, and that number is way too big, even divided by 1000.
EDIT:
std::cout<<std::fixed<<'\n'<<convert(timestamp.to_ullong());
std::cout<<std::fixed<<'\n'<<intpart;
-63578530899343.000000
-63578530899343.000000
I don't have any fractional part, I am maybe reading the bytes in a wrong order?