[PPL-devel] [GIT] ppl/ppl(master): Avoided some "magic constants".
Roberto Bagnara
bagnara at cs.unipr.it
Wed Aug 22 16:32:05 CEST 2012
Module: ppl/ppl
Branch: master
Commit: 55575dcac0fa329b196684941eded7123e3c34ff
URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=55575dcac0fa329b196684941eded7123e3c34ff
Author: Roberto Bagnara <bagnara at cs.unipr.it>
Date: Wed Aug 22 16:30:51 2012 +0200
Avoided some "magic constants".
Detected by ECLAIR service nomagicc.
---
src/Float.cc | 1 +
src/Float_defs.hh | 6 ++++++
src/Float_inlines.hh | 18 +++++++++---------
3 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/src/Float.cc b/src/Float.cc
index e79c04f..d20d5da 100644
--- a/src/Float.cc
+++ b/src/Float.cc
@@ -38,6 +38,7 @@ const uint64_t float_ieee754_quad::MSP_POS_ZERO;
const uint64_t float_ieee754_quad::MSP_NEG_ZERO;
const uint64_t float_ieee754_quad::LSP_INF;
const uint64_t float_ieee754_quad::LSP_ZERO;
+const uint64_t float_ieee754_quad::MSP_MAX;
const uint64_t float_ieee754_quad::LSP_MAX;
} // Parma_Polyhedra_Library
diff --git a/src/Float_defs.hh b/src/Float_defs.hh
index 1def00d..3b1060e 100644
--- a/src/Float_defs.hh
+++ b/src/Float_defs.hh
@@ -51,6 +51,7 @@ struct float_ieee754_half {
uint16_t word;
static const uint16_t SGN_MASK = 0x8000U;
static const uint16_t EXP_MASK = 0xfc00U;
+ static const uint16_t WRD_MAX = 0x7bffU;
static const uint16_t POS_INF = 0x7c00U;
static const uint16_t NEG_INF = 0xfc00U;
static const uint16_t POS_ZERO = 0x0000U;
@@ -83,6 +84,7 @@ struct float_ieee754_single {
uint32_t word;
static const uint32_t SGN_MASK = 0x80000000U;
static const uint32_t EXP_MASK = 0x7f800000U;
+ static const uint32_t WRD_MAX = 0x7f7fffffU;
static const uint32_t POS_INF = 0x7f800000U;
static const uint32_t NEG_INF = 0xff800000U;
static const uint32_t POS_ZERO = 0x00000000U;
@@ -131,6 +133,7 @@ struct float_ieee754_double {
static const uint32_t MSP_NEG_ZERO = 0x80000000U;
static const uint32_t LSP_INF = 0;
static const uint32_t LSP_ZERO = 0;
+ static const uint32_t MSP_MAX = 0x7fefffffU;
static const uint32_t LSP_MAX = 0xffffffffU;
static const unsigned int BASE = 2;
static const unsigned int EXPONENT_BITS = 11;
@@ -159,6 +162,7 @@ struct float_ibm_single {
uint32_t word;
static const uint32_t SGN_MASK = 0x80000000U;
static const uint32_t EXP_MASK = 0x7f000000U;
+ static const uint32_t WRD_MAX = 0x7fffffffU;
static const uint32_t POS_INF = 0x7f000000U;
static const uint32_t NEG_INF = 0xff000000U;
static const uint32_t POS_ZERO = 0x00000000U;
@@ -211,6 +215,7 @@ struct float_intel_double_extended {
static const uint32_t MSP_NEG_ZERO = 0x00008000U;
static const uint64_t LSP_INF = static_cast<uint64_t>(0x8000000000000000ULL);
static const uint64_t LSP_ZERO = 0;
+ static const uint32_t MSP_MAX = 0x00007ffeU;
static const uint64_t LSP_DMAX = static_cast<uint64_t>(0x7fffffffffffffffULL);
static const uint64_t LSP_NMAX = static_cast<uint64_t>(0xffffffffffffffffULL);
static const unsigned int BASE = 2;
@@ -252,6 +257,7 @@ struct float_ieee754_quad {
static const uint64_t MSP_NEG_ZERO = static_cast<uint64_t>(0x8000000000000000ULL);
static const uint64_t LSP_INF = 0;
static const uint64_t LSP_ZERO = 0;
+ static const uint64_t MSP_MAX = static_cast<uint64_t>(0x7ffeffffffffffffULL);
static const uint64_t LSP_MAX = static_cast<uint64_t>(0xffffffffffffffffULL);
static const unsigned int BASE = 2;
static const unsigned int EXPONENT_BITS = 15;
diff --git a/src/Float_inlines.hh b/src/Float_inlines.hh
index 50670de..47ae609 100644
--- a/src/Float_inlines.hh
+++ b/src/Float_inlines.hh
@@ -75,7 +75,7 @@ float_ieee754_half::inc() {
inline void
float_ieee754_half::set_max(bool negative) {
- word = 0x7bffU;
+ word = WRD_MAX;
if (negative)
word |= SGN_MASK;
}
@@ -136,7 +136,7 @@ float_ieee754_single::inc() {
inline void
float_ieee754_single::set_max(bool negative) {
- word = 0x7f7fffffU;
+ word = WRD_MAX;
if (negative)
word |= SGN_MASK;
}
@@ -212,8 +212,8 @@ float_ieee754_double::inc() {
inline void
float_ieee754_double::set_max(bool negative) {
- msp = 0x7fefffffU;
- lsp = 0xffffffffU;
+ msp = MSP_MAX;
+ lsp = LSP_MAX;
if (negative)
msp |= MSP_SGN_MASK;
}
@@ -283,7 +283,7 @@ float_ibm_single::inc() {
inline void
float_ibm_single::set_max(bool negative) {
- word = 0x7f000000U;
+ word = WRD_MAX;
if (negative)
word |= SGN_MASK;
}
@@ -361,8 +361,8 @@ float_intel_double_extended::inc() {
inline void
float_intel_double_extended::set_max(bool negative) {
- msp = 0x00007ffeU;
- lsp = static_cast<uint64_t>(0xffffffffffffffffULL);
+ msp = MSP_MAX;
+ lsp = LSP_NMAX;
if (negative)
msp |= MSP_SGN_MASK;
}
@@ -441,8 +441,8 @@ float_ieee754_quad::inc() {
inline void
float_ieee754_quad::set_max(bool negative) {
- msp = static_cast<uint64_t>(0x7ffeffffffffffffULL);
- lsp = static_cast<uint64_t>(0xffffffffffffffffULL);
+ msp = MSP_MAX;
+ lsp = LSP_MAX;
if (negative)
msp |= MSP_SGN_MASK;
}
More information about the PPL-devel
mailing list