When doing:
double a = 1000000000 / FPS;
It gives me the warning:
Integer division in floating point context.
How can I solve this?
The warning occurs because you divide two integers 1000000000 and FPS, and the variable you want to assign the result to is double, a floating point type.
What you want instead is having a floating point division.
For this, one of the operands of the division has to be a floating point type.
You can do it in the following ways:
1000000000.0 / FPS; // make operand a floating point type (double)
1000000000.0f / FPS; //(float)
1000000000d / FPS; //(double)
(double)1000000000 / FPS; // cast operand to a floating point type (may be necessary if your operand is a variable)
and of course you can make FPS just a floating point variable instead of a integer variable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With