[GIT] ppl/ppl(master): For clarity, renamed three-state Float method is_inf () as inf_sign().

Module: ppl/ppl Branch: master Commit: 2bcc4ac88501983c95dc035d8fc7ff5dbbf76975 URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=2bcc4ac885019...
Author: Enea Zaffanella zaffanella@cs.unipr.it Date: Wed Feb 15 14:39:43 2012 +0100
For clarity, renamed three-state Float method is_inf() as inf_sign(). Similarly, renamed is_zero() as zero_sign().
---
src/Float.defs.hh | 24 ++++++++++++------------ src/Float.inlines.hh | 24 ++++++++++++------------ src/checked_float.inlines.hh | 28 ++++++++++++++++------------ 3 files changed, 40 insertions(+), 36 deletions(-)
diff --git a/src/Float.defs.hh b/src/Float.defs.hh index 81e3799..597b2dc 100644 --- a/src/Float.defs.hh +++ b/src/Float.defs.hh @@ -65,9 +65,9 @@ struct float_ieee754_half { static const int EXPONENT_MIN_DENORM = EXPONENT_MIN - static_cast<int>(MANTISSA_BITS); static const Floating_Point_Format floating_point_format = IEEE754_HALF; - int is_inf() const; + int inf_sign() const; bool is_nan() const; - int is_zero() const; + int zero_sign() const; bool sign_bit() const; void negate(); void dec(); @@ -98,9 +98,9 @@ struct float_ieee754_single { static const int EXPONENT_MIN_DENORM = EXPONENT_MIN - static_cast<int>(MANTISSA_BITS); static const Floating_Point_Format floating_point_format = IEEE754_SINGLE; - int is_inf() const; + int inf_sign() const; bool is_nan() const; - int is_zero() const; + int zero_sign() const; bool sign_bit() const; void negate(); void dec(); @@ -144,9 +144,9 @@ struct float_ieee754_double { static const int EXPONENT_MIN_DENORM = EXPONENT_MIN - static_cast<int>(MANTISSA_BITS); static const Floating_Point_Format floating_point_format = IEEE754_DOUBLE; - int is_inf() const; + int inf_sign() const; bool is_nan() const; - int is_zero() const; + int zero_sign() const; bool sign_bit() const; void negate(); void dec(); @@ -176,9 +176,9 @@ struct float_ibm_single { static const int EXPONENT_MIN_DENORM = EXPONENT_MIN - static_cast<int>(MANTISSA_BITS); static const Floating_Point_Format floating_point_format = IBM_SINGLE; - int is_inf() const; + int inf_sign() const; bool is_nan() const; - int is_zero() const; + int zero_sign() const; bool sign_bit() const; void negate(); void dec(); @@ -229,9 +229,9 @@ struct float_intel_double_extended { - static_cast<int>(MANTISSA_BITS); static const Floating_Point_Format floating_point_format = INTEL_DOUBLE_EXTENDED; - int is_inf() const; + int inf_sign() const; bool is_nan() const; - int is_zero() const; + int zero_sign() const; bool sign_bit() const; void negate(); void dec(); @@ -268,9 +268,9 @@ struct float_ieee754_quad { static const int EXPONENT_MIN = -EXPONENT_MAX + 1; static const int EXPONENT_MIN_DENORM = EXPONENT_MIN - static_cast<int>(MANTISSA_BITS); - int is_inf() const; + int inf_sign() const; bool is_nan() const; - int is_zero() const; + int zero_sign() const; bool sign_bit() const; void negate(); void dec(); diff --git a/src/Float.inlines.hh b/src/Float.inlines.hh index c9b0108..88bb1a1 100644 --- a/src/Float.inlines.hh +++ b/src/Float.inlines.hh @@ -31,7 +31,7 @@ site: http://bugseng.com/products/ppl/ . */ namespace Parma_Polyhedra_Library {
inline int -float_ieee754_half::is_inf() const { +float_ieee754_half::inf_sign() const { if (word == NEG_INF) return -1; if (word == POS_INF) @@ -45,7 +45,7 @@ float_ieee754_half::is_nan() const { }
inline int -float_ieee754_half::is_zero() const { +float_ieee754_half::zero_sign() const { if (word == NEG_ZERO) return -1; if (word == POS_ZERO) @@ -92,7 +92,7 @@ float_ieee754_half::build(bool negative, mpz_t mantissa, int exponent) { }
inline int -float_ieee754_single::is_inf() const { +float_ieee754_single::inf_sign() const { if (word == NEG_INF) return -1; if (word == POS_INF) @@ -106,7 +106,7 @@ float_ieee754_single::is_nan() const { }
inline int -float_ieee754_single::is_zero() const { +float_ieee754_single::zero_sign() const { if (word == NEG_ZERO) return -1; if (word == POS_ZERO) @@ -153,7 +153,7 @@ float_ieee754_single::build(bool negative, mpz_t mantissa, int exponent) { }
inline int -float_ieee754_double::is_inf() const { +float_ieee754_double::inf_sign() const { if (lsp != LSP_INF) return 0; if (msp == MSP_NEG_INF) @@ -170,7 +170,7 @@ float_ieee754_double::is_nan() const { }
inline int -float_ieee754_double::is_zero() const { +float_ieee754_double::zero_sign() const { if (lsp != LSP_ZERO) return 0; if (msp == MSP_NEG_ZERO) @@ -239,7 +239,7 @@ float_ieee754_double::build(bool negative, mpz_t mantissa, int exponent) { }
inline int -float_ibm_single::is_inf() const { +float_ibm_single::inf_sign() const { if (word == NEG_INF) return -1; if (word == POS_INF) @@ -253,7 +253,7 @@ float_ibm_single::is_nan() const { }
inline int -float_ibm_single::is_zero() const { +float_ibm_single::zero_sign() const { if (word == NEG_ZERO) return -1; if (word == POS_ZERO) @@ -300,7 +300,7 @@ float_ibm_single::build(bool negative, mpz_t mantissa, int exponent) { }
inline int -float_intel_double_extended::is_inf() const { +float_intel_double_extended::inf_sign() const { if (lsp != LSP_INF) return 0; uint32_t a = msp & MSP_NEG_INF; @@ -318,7 +318,7 @@ float_intel_double_extended::is_nan() const { }
inline int -float_intel_double_extended::is_zero() const { +float_intel_double_extended::zero_sign() const { if (lsp != LSP_ZERO) return 0; uint32_t a = msp & MSP_NEG_INF; @@ -382,7 +382,7 @@ float_intel_double_extended::build(bool negative, }
inline int -float_ieee754_quad::is_inf() const { +float_ieee754_quad::inf_sign() const { if (lsp != LSP_INF) return 0; if (msp == MSP_NEG_INF) @@ -399,7 +399,7 @@ float_ieee754_quad::is_nan() const { }
inline int -float_ieee754_quad::is_zero() const { +float_ieee754_quad::zero_sign() const { if (lsp != LSP_ZERO) return 0; if (msp == MSP_NEG_ZERO) diff --git a/src/checked_float.inlines.hh b/src/checked_float.inlines.hh index 16fff99..ffb5bd0 100644 --- a/src/checked_float.inlines.hh +++ b/src/checked_float.inlines.hh @@ -153,11 +153,15 @@ classify_float(const T v, bool nan, bool inf, bool sign) { if ((nan || sign) && CHECK_P(Policy::has_nan, f.u.binary.is_nan())) return V_NAN; if (inf) { - int i = CHECK_P(Policy::has_infinity, f.u.binary.is_inf()); - if (i < 0) - return V_EQ_MINUS_INFINITY; - if (i > 0) - return V_EQ_PLUS_INFINITY; + if (Policy::has_infinity) { + int sign = f.u.binary.inf_sign(); + if (sign < 0) + return V_EQ_MINUS_INFINITY; + if (sign > 0) + return V_EQ_PLUS_INFINITY; + } + else + PPL_ASSERT(f.u.binary.inf_sign() == 0); } if (sign) { if (v < 0) @@ -180,20 +184,20 @@ template <typename Policy, typename T> inline bool is_inf_float(const T v) { Float<T> f(v); - return CHECK_P(Policy::has_infinity, (f.u.binary.is_inf() != 0)); + return CHECK_P(Policy::has_infinity, (f.u.binary.inf_sign() != 0)); } template <typename Policy, typename T> inline bool is_minf_float(const T v) { Float<T> f(v); - return CHECK_P(Policy::has_infinity, (f.u.binary.is_inf() < 0)); + return CHECK_P(Policy::has_infinity, (f.u.binary.inf_sign() == -1)); }
template <typename Policy, typename T> inline bool is_pinf_float(const T v) { Float<T> f(v); - return CHECK_P(Policy::has_infinity, (f.u.binary.is_inf() > 0)); + return CHECK_P(Policy::has_infinity, (f.u.binary.inf_sign() == 1)); }
@@ -228,8 +232,8 @@ inline void pred_float(T& v) { Float<T> f(v); PPL_ASSERT(!f.u.binary.is_nan()); - PPL_ASSERT(f.u.binary.is_inf() >= 0); - if (f.u.binary.is_zero() > 0) { + PPL_ASSERT(f.u.binary.inf_sign() >= 0); + if (f.u.binary.zero_sign() == 1) { f.u.binary.negate(); f.u.binary.inc(); } @@ -247,8 +251,8 @@ inline void succ_float(T& v) { Float<T> f(v); PPL_ASSERT(!f.u.binary.is_nan()); - PPL_ASSERT(f.u.binary.is_inf() <= 0); - if (f.u.binary.is_zero() < 0) { + PPL_ASSERT(f.u.binary.inf_sign() <= 0); + if (f.u.binary.zero_sign() == -1) { f.u.binary.negate(); f.u.binary.inc(); }
participants (1)
-
Enea Zaffanella