This is because 1/60 is an integer that is 0, because integer division is truncated. This is used to initialize the float, providing 0. .. You can fix this by making the RHS float expression first:
float controlFrameRate = 1.0f/60;
about
float controlFrameRate = 1/60.0f;
In C ++, literals such as 1 , 42 , etc., int , 1.0 , 3.1416 are double , and f in 1.0f makes a literal a float . Note that f could be excluded in the examples above. However, assigning a double value to a float can be problematic if the double value is outside the range of the float.
juanchopanza
source share