Fixed undefined behavior with log10 cast of fractional doubles (#276)

This commit is contained in:
Mikael Persson
2025-06-10 20:45:26 -04:00
committed by GitHub
parent 2f35c28a52
commit 708fff700f
2 changed files with 2 additions and 2 deletions

View File

@@ -91,7 +91,7 @@ TOML_ANON_NAMESPACE_START
weight += 1u;
val *= -1.0;
}
return weight + static_cast<size_t>(log10(val)) + 1u;
return weight + static_cast<size_t>(abs(log10(val))) + 1u;
}
case node_type::boolean: return 5u;

View File

@@ -17107,7 +17107,7 @@ TOML_ANON_NAMESPACE_START
weight += 1u;
val *= -1.0;
}
return weight + static_cast<size_t>(log10(val)) + 1u;
return weight + static_cast<size_t>(abs(log10(val))) + 1u;
}
case node_type::boolean: return 5u;