* ext/bigdecimal/bigdecimal.c (VPrint): be a static function, support another
dump formats, and add more information of the given bigdecimal. * ext/bigdecimal/bigdecimal.h: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44151 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
89b8502257
commit
27d53fb5df
@ -1,3 +1,10 @@
|
|||||||
|
Wed Dec 13 01:53:00 2013 Kenta Murata <mrkn@mrkn.jp>
|
||||||
|
|
||||||
|
* ext/bigdecimal/bigdecimal.c (VPrint): be a static function, support another
|
||||||
|
dump formats, and add more information of the given bigdecimal.
|
||||||
|
|
||||||
|
* ext/bigdecimal/bigdecimal.h: ditto.
|
||||||
|
|
||||||
Wed Dec 11 16:45:58 2013 Koichi Sasada <ko1@atdot.net>
|
Wed Dec 11 16:45:58 2013 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
* eval.c (rb_raise_jump): call c_return hook immediately after
|
* eval.c (rb_raise_jump): call c_return hook immediately after
|
||||||
|
@ -126,6 +126,10 @@ static void VpInternalRound(Real *c, size_t ixDigit, BDIGIT vPrev, BDIGIT v);
|
|||||||
static int VpLimitRound(Real *c, size_t ixDigit);
|
static int VpLimitRound(Real *c, size_t ixDigit);
|
||||||
static Real *VpCopy(Real *pv, Real const* const x);
|
static Real *VpCopy(Real *pv, Real const* const x);
|
||||||
|
|
||||||
|
#ifdef BIGDECIMAL_ENABLE_VPRINT
|
||||||
|
static int VPrint(FILE *fp,const char *cntl_chr,Real *a);
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* **** BigDecimal part ****
|
* **** BigDecimal part ****
|
||||||
*/
|
*/
|
||||||
@ -4940,7 +4944,6 @@ Exit:
|
|||||||
return (int)val;
|
return (int)val;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef BIGDECIMAL_ENABLE_VPRINT
|
|
||||||
/*
|
/*
|
||||||
* cntl_chr ... ASCIIZ Character, print control characters
|
* cntl_chr ... ASCIIZ Character, print control characters
|
||||||
* Available control codes:
|
* Available control codes:
|
||||||
@ -4951,10 +4954,11 @@ Exit:
|
|||||||
* Note: % must must not appear more than once
|
* Note: % must must not appear more than once
|
||||||
* a ... VP variable to be printed
|
* a ... VP variable to be printed
|
||||||
*/
|
*/
|
||||||
VP_EXPORT int
|
#ifdef BIGDECIMAL_ENABLE_VPRINT
|
||||||
|
static int
|
||||||
VPrint(FILE *fp, const char *cntl_chr, Real *a)
|
VPrint(FILE *fp, const char *cntl_chr, Real *a)
|
||||||
{
|
{
|
||||||
size_t i, j, nc, nd, ZeroSup;
|
size_t i, j, nc, nd, ZeroSup, sep = 10;
|
||||||
BDIGIT m, e, nn;
|
BDIGIT m, e, nn;
|
||||||
|
|
||||||
/* Check if NaN & Inf. */
|
/* Check if NaN & Inf. */
|
||||||
@ -4989,6 +4993,16 @@ VPrint(FILE *fp, const char *cntl_chr, Real *a)
|
|||||||
++nc;
|
++nc;
|
||||||
}
|
}
|
||||||
nc += fprintf(fp, "0.");
|
nc += fprintf(fp, "0.");
|
||||||
|
switch (*(cntl_chr + j + 1)) {
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '0': case 'z':
|
||||||
|
ZeroSup = 0;
|
||||||
|
++j;
|
||||||
|
sep = cntl_chr[j] == 'z' ? RMPD_COMPONENT_FIGURES : 10;
|
||||||
|
break;
|
||||||
|
}
|
||||||
for (i = 0; i < a->Prec; ++i) {
|
for (i = 0; i < a->Prec; ++i) {
|
||||||
m = BASE1;
|
m = BASE1;
|
||||||
e = a->frac[i];
|
e = a->frac[i];
|
||||||
@ -5001,7 +5015,7 @@ VPrint(FILE *fp, const char *cntl_chr, Real *a)
|
|||||||
++nd;
|
++nd;
|
||||||
ZeroSup = 0; /* Set to print succeeding zeros */
|
ZeroSup = 0; /* Set to print succeeding zeros */
|
||||||
}
|
}
|
||||||
if (nd >= 10) { /* print ' ' after every 10 digits */
|
if (nd >= sep) { /* print ' ' after every 10 digits */
|
||||||
nd = 0;
|
nd = 0;
|
||||||
nc += fprintf(fp, " ");
|
nc += fprintf(fp, " ");
|
||||||
}
|
}
|
||||||
@ -5010,6 +5024,7 @@ VPrint(FILE *fp, const char *cntl_chr, Real *a)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
nc += fprintf(fp, "E%"PRIdSIZE, VpExponent10(a));
|
nc += fprintf(fp, "E%"PRIdSIZE, VpExponent10(a));
|
||||||
|
nc += fprintf(fp, " (%"PRIdVALUE", %lu, %lu)", a->exponent, a->Prec, a->MaxPrec);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
nc += fprintf(fp, "0.0");
|
nc += fprintf(fp, "0.0");
|
||||||
@ -5043,9 +5058,10 @@ VPrint(FILE *fp, const char *cntl_chr, Real *a)
|
|||||||
}
|
}
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (int)nc;
|
return (int)nc;
|
||||||
}
|
}
|
||||||
#endif /* BIGDECIMAL_ENABLE_VPRINT */
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
VpFormatSt(char *psz, size_t fFmt)
|
VpFormatSt(char *psz, size_t fFmt)
|
||||||
|
@ -310,7 +310,6 @@ VP_EXPORT Real *VpOne(void);
|
|||||||
#define VpExponent(a) (a->exponent)
|
#define VpExponent(a) (a->exponent)
|
||||||
#ifdef BIGDECIMAL_DEBUG
|
#ifdef BIGDECIMAL_DEBUG
|
||||||
int VpVarCheck(Real * v);
|
int VpVarCheck(Real * v);
|
||||||
VP_EXPORT int VPrint(FILE *fp,const char *cntl_chr,Real *a);
|
|
||||||
#endif /* BIGDECIMAL_DEBUG */
|
#endif /* BIGDECIMAL_DEBUG */
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user