mirror of
https://github.com/Redot-Engine/redot-engine.git
synced 2025-12-06 15:21:56 -05:00
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:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user