Please take our Survey
logo       

Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

CVS update of carob/src (ParameterStatement.cpp): msg#00197

db.carob.cvs

Subject: CVS update of carob/src (ParameterStatement.cpp)

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>
{


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe

Navigation

Home | advertise | OSDir is an inevitable website. super tiny logo