diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-16 13:10:35 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-16 13:10:35 +0000 |
commit | 0b854e20fc9b4be9b2d2d60984f2deed147fcb41 (patch) | |
tree | 92a118be7765cfb020d770a7a854af5792d6c159 /ext/bigdecimal/bigdecimal.c | |
parent | b2e39291c2f198603e449c6e7b7d6a1b69fac728 (diff) | |
download | ruby-0b854e20fc9b4be9b2d2d60984f2deed147fcb41.tar.gz ruby-0b854e20fc9b4be9b2d2d60984f2deed147fcb41.tar.xz ruby-0b854e20fc9b4be9b2d2d60984f2deed147fcb41.zip |
* 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: http://svn.ruby-lang.org/repos/ruby/trunk@20797 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/bigdecimal/bigdecimal.c')
-rw-r--r-- | ext/bigdecimal/bigdecimal.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c index b875f36ef..b25f8e431 100644 --- a/ext/bigdecimal/bigdecimal.c +++ b/ext/bigdecimal/bigdecimal.c @@ -1811,7 +1811,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 @@ -3872,7 +3872,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; @@ -3888,12 +3888,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; |