I would like to convert an int64_t value [nanoseconds] into a float (or double) [seconds] value.
So I tried the following:
int64_t elapsed_nano = 7079206912L;
printf("%f\n", float(elapsed_nano));
float elapsed_sec = float(elapsed_nano) / float(1000000000);
printf("%f\n", elapsed_sec);
That seems to cut off some of the last bit .. probably due to some internal rounding. Here the output:
7079206912.000000
7.079207
I tried to multiply with float(0.000000001)
instead, but that did not help.
I guess best would be, to just change the exponent of the float, though I did not find any documentation on how that can be done.
I am using gcc 4.8.5 (cannot update to a more recent gcc for different reasons)