Core: Replace C math headers with C++ equivalents

- Minor restructuring to ensure `math_funcs.h` is the central point for math functions
This commit is contained in:
Thaddeus Crews
2025-03-19 14:18:09 -05:00
parent c5c1cd4440
commit ad40939b6f
101 changed files with 414 additions and 498 deletions

View File

@@ -248,8 +248,8 @@ TEST_CASE("[JSON] Serialization") {
{ -1000.1234567890123456789, "-1000.12345678901" },
{ DBL_MAX, "179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0" },
{ DBL_MAX - 1, "179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0" },
{ pow(2, 53), "9007199254740992.0" },
{ -pow(2, 53), "-9007199254740992.0" },
{ std::pow(2, 53), "9007199254740992.0" },
{ -std::pow(2, 53), "-9007199254740992.0" },
{ 0.00000000000000011, "0.00000000000000011" },
{ -0.00000000000000011, "-0.00000000000000011" },
{ 1.0 / 3.0, "0.333333333333333" },
@@ -263,8 +263,8 @@ TEST_CASE("[JSON] Serialization") {
{ -1000.1234567890123456789, "-1000.12345678901238" },
{ DBL_MAX, "179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0" },
{ DBL_MAX - 1, "179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0" },
{ pow(2, 53), "9007199254740992.0" },
{ -pow(2, 53), "-9007199254740992.0" },
{ std::pow(2, 53), "9007199254740992.0" },
{ -std::pow(2, 53), "-9007199254740992.0" },
{ 0.00000000000000011, "0.00000000000000011" },
{ -0.00000000000000011, "-0.00000000000000011" },
{ 1.0 / 3.0, "0.333333333333333315" },

View File

@@ -258,7 +258,7 @@ TEST_CASE_MAY_FAIL("[RandomNumberGenerator] randi_range bias check") {
int val = rng->randi_range(0, 1);
val == 0 ? zeros++ : ones++;
}
CHECK_MESSAGE(abs(zeros * 1.0 / ones - 1.0) < 0.1, "The ratio of zeros to ones should be nearly 1");
CHECK_MESSAGE(std::abs(zeros * 1.0 / ones - 1.0) < 0.1, "The ratio of zeros to ones should be nearly 1");
int vals[10] = { 0 };
for (int i = 0; i < 1000000; i++) {
@@ -266,7 +266,7 @@ TEST_CASE_MAY_FAIL("[RandomNumberGenerator] randi_range bias check") {
}
for (int i = 0; i < 10; i++) {
CHECK_MESSAGE(abs(vals[i] / 1000000.0 - 0.1) < 0.01, "Each element should appear roughly 10% of the time");
CHECK_MESSAGE(std::abs(vals[i] / 1000000.0 - 0.1) < 0.01, "Each element should appear roughly 10% of the time");
}
}
} // namespace TestRandomNumberGenerator