From 5eef94c8ced11a5d39c38566492cf059c92d8ad2 Mon Sep 17 00:00:00 2001 From: shyouhei Date: Fri, 12 Jun 2009 07:39:31 +0000 Subject: merge revision(s) 23662: * 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_7@23671 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/bigdecimal/bigdecimal.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'ext') diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c index 4264d22c9f..03fafaf0d7 100644 --- a/ext/bigdecimal/bigdecimal.c +++ b/ext/bigdecimal/bigdecimal.c @@ -3803,7 +3803,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; @@ -3819,12 +3819,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; -- cgit v1.2.3