|
|
|
|
|
by sltkr
735 days ago
|
|
Although using constexpr over #define wherever possible is good advice (and similarly with functions over macros), you can also argue that the culprit is really this snippet: float ts = 1 / FRAMERATE;
This blindly assumes that FRAMERATE is a floating-point constant, but there is no reason to assume it is; in theory, other parts of the code could depend on FRAMERATE being integral. The code should be written in a way that ensures conversion to float happens before division, for example: float ts = 1.0f / FRAMERATE;
|
|
C++ gets this wrong for maximum drop-in compatibility with C, the classic "New Jersey Style" programming language where simplicity of implementation is prized over simplicity of use or correctness.