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

@@ -1579,7 +1579,7 @@ String String::num(double p_num, int p_decimals) {
}
if (Math::is_inf(p_num)) {
if (signbit(p_num)) {
if (std::signbit(p_num)) {
return "-inf";
} else {
return "inf";
@@ -1592,7 +1592,7 @@ String String::num(double p_num, int p_decimals) {
if (abs_num > 10) {
// We want to align the digits to the above reasonable default, so we only
// need to subtract log10 for numbers with a positive power of ten.
p_decimals -= (int)floor(log10(abs_num));
p_decimals -= (int)std::floor(std::log10(abs_num));
}
}
if (p_decimals > MAX_DECIMALS) {
@@ -1758,7 +1758,7 @@ String String::num_real(double p_num, bool p_trailing) {
// to subtract log10 for numbers with a positive power of ten magnitude.
const double abs_num = Math::abs(p_num);
if (abs_num > 10) {
decimals -= (int)floor(log10(abs_num));
decimals -= (int)std::floor(std::log10(abs_num));
}
return num(p_num, decimals);
@@ -1781,7 +1781,7 @@ String String::num_real(float p_num, bool p_trailing) {
// to subtract log10 for numbers with a positive power of ten magnitude.
const float abs_num = Math::abs(p_num);
if (abs_num > 10) {
decimals -= (int)floor(log10(abs_num));
decimals -= (int)std::floor(std::log10(abs_num));
}
return num(p_num, decimals);
}
@@ -5755,7 +5755,7 @@ String String::sprintf(const Array &values, bool *error) const {
}
double value = values[value_index];
bool is_negative = signbit(value);
bool is_negative = std::signbit(value);
String str = String::num(Math::abs(value), min_decimals);
const bool is_finite = Math::is_finite(value);