diff --git a/src/lol/math/real.h b/src/lol/math/real.h index bf9f655b..631c4fc5 100644 --- a/src/lol/math/real.h +++ b/src/lol/math/real.h @@ -109,7 +109,6 @@ public: template friend Real frexp(Real const &x, int *exp); template friend Real ldexp(Real const &x, int exp); template friend Real modf(Real const &x, Real *iptr); - template friend Real ulp(Real const &x); template friend Real nextafter(Real const &x, Real const &y); /* Power functions */ @@ -200,11 +199,15 @@ public: static Real const& R_SQRT3(); static Real const& R_SQRT1_2(); + static Real const& R_MIN(); + static Real const& R_MAX(); + /* XXX: changing this requires tuning real::fres (the number of * Newton-Raphson iterations) and real::print (the number of printed * digits) */ static int const BIGITS = N; static int const BIGIT_BITS = 32; + static int const TOTAL_BITS = BIGITS * BIGIT_BITS; private: uint32_t *m_mantissa; @@ -274,7 +277,6 @@ template Real log10(Real const &x); template Real frexp(Real const &x, int *exp); template Real ldexp(Real const &x, int exp); template Real modf(Real const &x, Real *iptr); -template Real ulp(Real const &x); template Real nextafter(Real const &x, Real const &y); template Real inverse(Real const &x); template Real sqrt(Real const &x); @@ -314,7 +316,6 @@ template<> real log10(real const &x); template<> real frexp(real const &x, int *exp); template<> real ldexp(real const &x, int exp); template<> real modf(real const &x, real *iptr); -template<> real ulp(real const &x); template<> real nextafter(real const &x, real const &y); template<> real inverse(real const &x); template<> real sqrt(real const &x); diff --git a/src/math/real.cpp b/src/math/real.cpp index a352a65d..777b45bf 100644 --- a/src/math/real.cpp +++ b/src/math/real.cpp @@ -34,6 +34,7 @@ namespace lol static real fast_log(real const &x); static real fast_pi(); +static real fast_min(); #define LOL_CONSTANT_GETTER(name, value) \ template<> real const& real::name() \ @@ -48,6 +49,9 @@ LOL_CONSTANT_GETTER(R_2, (real)2.0); LOL_CONSTANT_GETTER(R_3, (real)3.0); LOL_CONSTANT_GETTER(R_10, (real)10.0); +LOL_CONSTANT_GETTER(R_MAX, ldexp(R_1(), (1 << 30)); +LOL_CONSTANT_GETTER(R_MIN, ldexp(R_1(), 1 - (1 << 30)); + LOL_CONSTANT_GETTER(R_LN2, fast_log(R_2())); LOL_CONSTANT_GETTER(R_LN10, log(R_10())); LOL_CONSTANT_GETTER(R_LOG2E, inverse(R_LN2()));