I am trying to get unix timestamp upto milliseconds in float whenever I call this function which is probably 30 times/second. The timestamp that the function below returns is always the same however, when I print it to
float milliseconds_since_epoch =
std::cerr << milliseconds_since_epoch << std::endl;
float's precision is not good enough to do what you want here. The current number of milliseconds since 1970-01-01 is about 1,478,020,169,728. The next representable value in a
float after this is 1,478,020,300,800. That is about 131s (2min) later.
double will do here.