|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r73951 - in sandbox/e_float/libs/e_float: src/e_float/efx test/naive_test
From: e_float_at_[hidden]
Date: 2011-08-20 11:04:13
Author: christopher_kormanyos
Date: 2011-08-20 11:04:12 EDT (Sat, 20 Aug 2011)
New Revision: 73951
URL: http://svn.boost.org/trac/boost/changeset/73951
Log:
- Added additional overflow and underflow handling.
Text files modified:
sandbox/e_float/libs/e_float/src/e_float/efx/e_float_efx.cpp | 30 ++++++++++++++++++++++--------
sandbox/e_float/libs/e_float/test/naive_test/naive_test.cpp | 2 +-
2 files changed, 23 insertions(+), 9 deletions(-)
Modified: sandbox/e_float/libs/e_float/src/e_float/efx/e_float_efx.cpp
==============================================================================
--- sandbox/e_float/libs/e_float/src/e_float/efx/e_float_efx.cpp (original)
+++ sandbox/e_float/libs/e_float/src/e_float/efx/e_float_efx.cpp 2011-08-20 11:04:12 EDT (Sat, 20 Aug 2011)
@@ -645,6 +645,10 @@
}
}
+ // Check for underflow.
+ if(iszero()) { return (*this = ef::zero()); }
+
+ // Check for overflow.
if( (exp >= std::numeric_limits<e_float>::max_exponent10)
&& (ef::fabs(*this) > (std::numeric_limits<e_float>::max)())
)
@@ -927,12 +931,7 @@
}
// Check for underflow.
- if( (exp <= std::numeric_limits<e_float>::min_exponent10)
- && (*this < (std::numeric_limits<e_float>::min)())
- )
- {
- return (*this = ef::zero());
- }
+ if(iszero()) { return (*this = ef::zero()); }
// Set the sign of the result.
neg = b_neg;
@@ -1844,9 +1843,24 @@
}
// ...and check for underflow.
- if(exp < std::numeric_limits<e_float>::min_exponent10)
+ if(exp <= std::numeric_limits<e_float>::min_exponent10)
{
- *this = ef::zero();
+ if(exp == std::numeric_limits<e_float>::min_exponent10)
+ {
+ // Check for identity with the minimum value.
+ e_float test = *this;
+
+ test.exp = static_cast<INT64>(0);
+
+ if(test.isone())
+ {
+ *this = ef::zero();
+ }
+ }
+ else
+ {
+ *this = ef::zero();
+ }
}
return true;
Modified: sandbox/e_float/libs/e_float/test/naive_test/naive_test.cpp
==============================================================================
--- sandbox/e_float/libs/e_float/test/naive_test/naive_test.cpp (original)
+++ sandbox/e_float/libs/e_float/test/naive_test/naive_test.cpp 2011-08-20 11:04:12 EDT (Sat, 20 Aug 2011)
@@ -512,4 +512,4 @@
//3.14159265358979323846264338327950288419716939937511
//3.141592653589793238462643383279502884197169399375105820974944
//3.141592653589793115997963468544185161590576171875
-// ^ differs from double at 17th digit.
\ No newline at end of file
+// ^ differs from double at 17th digit.
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk