forked from ddnet/ddnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix inaccurate envelope point value rounding
Round to nearest integer instead of truncating in `f2fx` to ensure correct round-trip with `fx2f`. Add test to ensure correct round-trip with maximum `0.0005f` absolute error.
- Loading branch information
Showing
3 changed files
with
15 additions
and
1 deletion.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include "test.h" | ||
#include <gtest/gtest.h> | ||
|
||
#include <base/math.h> | ||
|
||
TEST(Math, FixedPointRoundtrip) | ||
{ | ||
for(int i = 0; i < 100000; ++i) | ||
{ | ||
const float Number = i / 1000.0f; | ||
EXPECT_NEAR(Number, fx2f(f2fx(Number)), 0.0005f); | ||
} | ||
} |