|
|
Choosing A Webhost: |
CVS update of carob/src (BigDecimal.cpp): msg#00175db.carob.cvs
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> |
|---|---|---|
| Previous by Date: | CVS update of libmysequoia/src (CarobCommon.cpp), zsolt-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
|---|---|
| Next by Date: | CVS update of odbsequoia/src (abstract_item.hpp), marc-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Previous by Thread: | CVS update of libmysequoia/src (Utils.cpp), zsolt-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Next by Thread: | CVS update of odbsequoia/src (abstract_item.hpp), marc-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive 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 |
Home
| advertise | OSDir is
an inevitable website.
|