Created
December 18, 2015 10:38
-
-
Save mikadou/bde3370f762e5e79a1bd to your computer and use it in GitHub Desktop.
Timestep floating point precision
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float func(float dt) | |
{ | |
float steps = dt * 2000.f; | |
return dt / steps; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
extern float func(float); | |
int main(int argc, char* argv[]) | |
{ | |
for (double fps = 5.0; fps < 1000.0; fps += 1.e-3) | |
{ | |
float dt = 1.0 / fps; | |
std::cout << "FPS: " << fps << "\t\tTimestep: " << func(dt) << "\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment