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 (BigDecimal.cpp): msg#00175

db.carob.cvs

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

Date: Thursday, March 30, 2006 @ 14:19:07
Author: gilles
Path: /cvsroot/carob/carob/src

Modified: BigDecimal.cpp (1.25 -> 1.26)

Removed signum == 0 optimization that was leading to wrong display of 0.000 (0
with scale 3)


----------------+
BigDecimal.cpp | 34 +++++++++++++++-------------------
1 files changed, 15 insertions(+), 19 deletions(-)


Index: carob/src/BigDecimal.cpp
diff -u carob/src/BigDecimal.cpp:1.25 carob/src/BigDecimal.cpp:1.26
--- carob/src/BigDecimal.cpp:1.25 Thu Mar 23 15:37:04 2006
+++ carob/src/BigDecimal.cpp Thu Mar 30 14:19:07 2006
@@ -323,29 +323,25 @@
// FIXME: this function can be optimized: lots of front-inserts can be avoided
std::wstring BigDecimal::toString(const wchar_t decimal_point) const
{
- wstring sRet(L"0");
- if (signum != 0) // 0 signum means 0 value => no useless computations !
+ //convert to string, then to wstring (no direct mpz->wstring converter)
+ std::ostringstream buffer;
+ buffer << unscaled_value;
+ wstring sRet = fromString(buffer.str());
+ int sRetLength = static_cast<int>(sRet.length());
+ if (scale != 0)
{
- //convert to string, then to wstring (no direct mpz->wstring converter)
- std::ostringstream buffer;
- buffer << unscaled_value;
- sRet = fromString(buffer.str());
- int sRetLength = static_cast<int>(sRet.length());
- if (scale != 0)
+ if (sRetLength <= scale)
{
- if (sRetLength <= scale)
- {
- // add heading zeros as needed
- sRet.insert(0, scale - sRetLength + 1, L'0');
- }
- // insert the decimal point
- sRet.insert(sRet.length()-scale, 1, decimal_point);
+ // add heading zeros as needed
+ sRet.insert(0, scale - sRetLength + 1, L'0');
}
- // and the optional sign
- if (signum < 0)
- sRet.insert(0, L"-");
-
+ // insert the decimal point
+ sRet.insert(sRet.length()-scale, 1, decimal_point);
}
+ // and the optional sign
+ if (signum < 0)
+ sRet.insert(0, L"-");
+
return sRet;
}


<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