Skip to content
33 changes: 1 addition & 32 deletions stl/inc/cmath
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ _STL_DISABLE_CLANG_WARNINGS
#pragma push_macro("new")
#undef new

_NODISCARD _Check_return_ inline double pow(_In_ double _Xx, _In_ int _Yx) noexcept /* strengthened */ {
if (_Yx == 2) {
return _Xx * _Xx;
}

return _CSTD pow(_Xx, static_cast<double>(_Yx));
}

_NODISCARD _Check_return_ inline float acos(_In_ float _Xx) noexcept /* strengthened */ {
return _CSTD acosf(_Xx);
}
Expand Down Expand Up @@ -199,14 +191,6 @@ _NODISCARD _Check_return_ inline float pow(_In_ float _Xx, _In_ float _Yx) noexc
return _CSTD powf(_Xx, _Yx);
}

_NODISCARD _Check_return_ inline float pow(_In_ float _Xx, _In_ int _Yx) noexcept /* strengthened */ {
if (_Yx == 2) {
return _Xx * _Xx;
}

return _CSTD powf(_Xx, static_cast<float>(_Yx));
}

_NODISCARD _Check_return_ inline float remainder(_In_ float _Xx, _In_ float _Yx) noexcept /* strengthened */ {
return _CSTD remainderf(_Xx, _Yx);
}
Expand Down Expand Up @@ -442,14 +426,6 @@ _NODISCARD _Check_return_ inline long double pow(_In_ long double _Xx, _In_ long
return _CSTD powl(_Xx, _Yx);
}

_NODISCARD _Check_return_ inline long double pow(_In_ long double _Xx, _In_ int _Yx) noexcept /* strengthened */ {
if (_Yx == 2) {
return _Xx * _Xx;
}

return _CSTD powl(_Xx, static_cast<long double>(_Yx));
}

_NODISCARD _Check_return_ inline long double remainder(_In_ long double _Xx, _In_ long double _Yx) noexcept
/* strengthened */ {
return _CSTD remainderl(_Xx, _Yx);
Expand Down Expand Up @@ -517,13 +493,6 @@ double frexp(_Ty _Value, _Out_ int* const _Exp) noexcept /* strengthened */ {
return _CSTD frexp(static_cast<double>(_Value), _Exp);
}

// FUNCTION TEMPLATE pow
template <class _Ty1, class _Ty2, _STD enable_if_t<_STD is_arithmetic_v<_Ty1> && _STD is_arithmetic_v<_Ty2>, int> = 0>
_NODISCARD _STD _Common_float_type_t<_Ty1, _Ty2> pow(const _Ty1 _Left, const _Ty2 _Right) noexcept /* strengthened */ {
using _Common = _STD _Common_float_type_t<_Ty1, _Ty2>;
return _CSTD pow(static_cast<_Common>(_Left), static_cast<_Common>(_Right));
}

// FUNCTION TEMPLATE fma
#if !_HAS_IF_CONSTEXPR
inline float _Fma(float _Left, float _Middle, float _Right) noexcept {
Expand Down Expand Up @@ -643,7 +612,7 @@ _GENERIC_MATH1(cbrt)
_GENERIC_MATH1(fabs)
_GENERIC_MATH2(hypot)
// 3-arg hypot() is hand-crafted
// pow() is hand-crafted
_GENERIC_MATH2(pow)
_GENERIC_MATH1(sqrt)
_GENERIC_MATH1(erf)
_GENERIC_MATH1(erfc)
Expand Down
2 changes: 1 addition & 1 deletion tests/std/tests/VSO_0099869_pow_float_overflow/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class test_std_pow_against_crt {

void single(uint32_t baseCandidate) {
float input = reinterpret_as<float>(baseCandidate);
float powOut = std::pow(input, 2);
float powOut = input * input;
float powfOut = powf(input, 2.0f);
int powClass = fpclassify(powOut);
int powfClass = fpclassify(powfOut);
Expand Down
4 changes: 4 additions & 0 deletions tests/tr1/tests/cmath1/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include "tdefs.h"
#include <cmath>

#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)

static const double e = (double) 2.7182818284590452353602874713526625L;
static const double ln2 = (double) 0.69314718055994530941723212145817657L;
static const double pi3by4 = (double) 2.35619449019234492884698253745962716L;
Expand Down Expand Up @@ -50,6 +52,8 @@ void test_cpp() { // test C++ header

double (*pabs)(double) = &STD abs; // C++ overloads
CHECK((*pabs)(-rthalf) == rthalf);

STATIC_ASSERT(std::is_same<decltype(std::pow(10.0, 2)), double>::value);
}

void test_main() { // test basic workings of cmath definitions
Expand Down
4 changes: 4 additions & 0 deletions tests/tr1/tests/cmath2/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include "tdefs.h"
#include <cmath>

#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)

static const float e = (float) 2.7182818284590452353602874713526625L;
static const float ln2 = (float) 0.69314718055994530941723212145817657L;
static const float pi3by4 = (float) 2.35619449019234492884698253745962716L;
Expand Down Expand Up @@ -94,6 +96,8 @@ void test_cpp() { // test C++ header
CHECK(approx((*psqrt)(2.0F), 1.0F / rthalf));
float (*ptanh)(float) = &STDx tanh;
CHECK(approx((*ptanh)(-1.0F), -(e * e - 1.0F) / (e * e + 1.0F)));

STATIC_ASSERT(std::is_same<decltype(std::pow(10.0f, 2)), double>::value);
}

void test_main() { // test basic workings of cmath definitions
Expand Down
4 changes: 4 additions & 0 deletions tests/tr1/tests/cmath3/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include "tdefs.h"
#include <cmath>

#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)

static const long double e = 2.7182818284590452353602874713526625L;
static const long double ln2 = 0.69314718055994530941723212145817657L;
static const long double pi3by4 = 2.35619449019234492884698253745962716L;
Expand Down Expand Up @@ -94,6 +96,8 @@ void test_cpp() { // test C++ header
CHECK(approx((*psqrt)(2.0L), 1.0L / rthalf));
long double (*ptanh)(long double) = &STDx tanh;
CHECK(approx((*ptanh)(-1.0L), -(e * e - 1.0L) / (e * e + 1.0L)));

STATIC_ASSERT(std::is_same<decltype(std::pow(10.0l, 2)), long double>::value);
}

void test_main() { // test basic workings of cmath definitions
Expand Down