Date: Friday, January 27, 2006 @ 16:06:42
Author: marc
Path: /cvsroot/carob/carob/src
Modified: ParameterStatement.cpp (1.12 -> 1.13)
Added lengthy explanation & references about the right precision() to use to
print floating point numbers.
------------------------+
ParameterStatement.cpp | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+)
Index: carob/src/ParameterStatement.cpp
diff -u carob/src/ParameterStatement.cpp:1.12
carob/src/ParameterStatement.cpp:1.13
--- carob/src/ParameterStatement.cpp:1.12 Fri Jan 27 15:54:00 2006
+++ carob/src/ParameterStatement.cpp Fri Jan 27 16:06:42 2006
@@ -196,6 +196,26 @@
///// Filter specializations ////
// Partial specialization code shared by float & double
+
+// std::numeric_limits<...>::digits10 is not the precision we want, cause
+// digits10 is the maximum number of base10 digits that (float|double)
+// can hold without loss, whereas we want the opposite: the minimum
+// number of base10 digits required to describe any (float|double
+// value) without loss.
+
+// g++ 4.0.2 defines for instance:
+// <float>::digits10 = 6 and <double>::digits10 = 15
+
+// For IEEE754's floats the required base10 precision is 9 (nine),
+// and for IEEE754's doubles it's 17 (seventeen)
+// We add one digit for some safety wrt to buggy converters (but if
+// they are really too buggy this won't be enough to save us)
+
+// In scientific mode, we have:
+// ios_base::precision() digits _after_ comma, +1 digit _before_ comma
+
+// See paragraph "Conversions" at:
+// http://www2.hursley.ibm.com/decimal/ for more details and proofs.
template<class Ch> void
streamSettingsForFloatingPoint(basic_ostream<Ch>& s)
{
@@ -204,6 +224,7 @@
}
// template specialization for float
+
template<class Ch>
class streamSettings<float, Ch>
{
_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits