summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-17 06:18:38 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-17 06:18:38 +0000
commit77da5d140bfa3000537ab78a01b9285238176aa3 (patch)
tree48865fcb01a9d180e5f83484e78d890473fc09e6 /ext
parent92011ee8483595986ba9c339a32b1712af546f55 (diff)
merges r20797 from trunk into ruby_1_9_1.
* ext/bigdecimal/bigdecimal.c (VpToString): reverted modification (that caused a bug) in r20359. [ruby-dev:37370] * ext/bigdecimal/bigdecimal.c (BigDecimal_limit): comment update. [ruby-dev:37465] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@20832 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/bigdecimal/bigdecimal.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index 0a43570903..b21041a329 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -1797,7 +1797,7 @@ BigDecimal_new(int argc, VALUE *argv, VALUE self)
*
* A limit of 0, the default, means no upper limit.
*
- * The limit specified by this method takes priority over any limit
+ * The limit specified by this method takes less priority over any limit
* specified to instance methods such as ceil, floor, truncate, or round.
*/
static VALUE
@@ -3858,7 +3858,7 @@ VpToString(Real *a,char *psz,int fFmt,int fPlus)
/* fPlus =0:default, =1: set ' ' before digits , =2:set '+' before digits. */
{
U_LONG i, ZeroSup;
- U_LONG n, e;
+ U_LONG n, m, e, nn;
char *pszSav = psz;
S_LONG ex;
@@ -3874,12 +3874,18 @@ VpToString(Real *a,char *psz,int fFmt,int fPlus)
*psz++ = '.';
n = a->Prec;
for(i=0;i < n;++i) {
+ m = BASE1;
e = a->frac[i];
- if((!ZeroSup) || e) {
- sprintf(psz, "%lu", e); /* The reading zero(s) */
- psz += strlen(psz);
- /* as 0.00xx will be ignored. */
- ZeroSup = 0; /* Set to print succeeding zeros */
+ while(m) {
+ nn = e / m;
+ if((!ZeroSup) || nn) {
+ sprintf(psz, "%lu", nn); /* The reading zero(s) */
+ psz += strlen(psz);
+ /* as 0.00xx will be ignored. */
+ ZeroSup = 0; /* Set to print succeeding zeros */
+ }
+ e = e - nn * m;
+ m /= 10;
}
}
ex =(a->exponent) * BASE_FIG;