summaryrefslogtreecommitdiff
path: root/ext/bigdecimal/bigdecimal.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-06-11 04:34:41 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-06-11 04:34:41 +0000
commit5e183bb4b2c1b135545bc8dbad2f1ac0b64ffee5 (patch)
tree8fe17c29e2151d6cd1dc7113e613f30544ea9c23 /ext/bigdecimal/bigdecimal.c
parent593f383b24ab4c95d7eee6bdecc0327dfd9ec59f (diff)
* ext/bigdecimal/bigdecimal.c (VpToString): fixed a bug introduced
in r23613. [ruby-talk:338957] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@23662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/bigdecimal/bigdecimal.c')
-rw-r--r--ext/bigdecimal/bigdecimal.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index 713965dbad..60751a84b7 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -3805,7 +3805,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;
@@ -3821,12 +3821,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;