How does one solve the "integer division in floating-point context" warning, in this line of code:
int fps = 60;
double timePerTick = 1000000000 / fps;
When dividing two int
s, you'll be using integer division, and only then promoting the result to a double, losing all the precision after the decimal point. You can use floating point precision by using a double
literal instead:
double timePerTick = 1000000000.0 / fps;
// Here -----------------------^