Skip to content

Instantly share code, notes, and snippets.

@mikadou
Created December 18, 2015 10:38
Show Gist options
  • Save mikadou/bde3370f762e5e79a1bd to your computer and use it in GitHub Desktop.
Save mikadou/bde3370f762e5e79a1bd to your computer and use it in GitHub Desktop.
Timestep floating point precision
float func(float dt)
{
float steps = dt * 2000.f;
return dt / steps;
}
#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