Merge pull request #104386 from Repiteo/core/cpp-math
Core: Replace C math headers with C++ equivalents
This commit is contained in:
@ -1445,7 +1445,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";
|
||||
@ -1458,7 +1458,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) {
|
||||
@ -1624,7 +1624,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);
|
||||
@ -1647,7 +1647,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);
|
||||
}
|
||||
@ -5621,7 +5621,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