From 606c473683f53af6be614bec8fdb5c7a7d0e974d Mon Sep 17 00:00:00 2001 From: shigek Date: Fri, 8 Aug 2003 15:31:27 +0000 Subject: F style output(like 1234.56789) implemented to to_s method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4356 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/bigdecimal/bigdecimal.c | 297 +++++++++++++++++++++++++++----------- ext/bigdecimal/bigdecimal.h | 5 +- ext/bigdecimal/bigdecimal_en.html | 36 +++-- ext/bigdecimal/bigdecimal_ja.html | 37 +++-- 4 files changed, 267 insertions(+), 108 deletions(-) (limited to 'ext/bigdecimal') diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c index 8f0ab8bd67..e850fbd047 100644 --- a/ext/bigdecimal/bigdecimal.c +++ b/ext/bigdecimal/bigdecimal.c @@ -197,7 +197,7 @@ BigDecimal_dump(int argc, VALUE *argv, VALUE self) rb_scan_args(argc, argv, "01", &dummy); GUARD_OBJ(vp,GetVpValue(self,1)); sprintf(sz,"%lu:",VpMaxPrec(vp)*VpBaseFig()); - psz = ALLOCA_N(char,(unsigned int)VpNumOfChars(vp)+strlen(sz)); + psz = ALLOCA_N(char,(unsigned int)VpNumOfChars(vp,"E")+strlen(sz)); sprintf(psz,"%s",sz); VpToString(vp, psz+strlen(psz), 0); return rb_str_new2(psz); @@ -233,13 +233,17 @@ BigDecimal_mode(VALUE self, VALUE which, VALUE val) { unsigned long f,fo; - if(TYPE(which)!=T_FIXNUM) return Qnil; + Check_Type(which, T_FIXNUM); f = (unsigned long)FIX2INT(which); - if(f&VP_EXCEPTION_ALL) { + if(f&VP_EXCEPTION_ALL) { /* Exception mode setting */ fo = VpGetException(); - if(val!=Qfalse && val!=Qtrue) return Qnil; + if(val==Qnil) return INT2FIX(fo); + if(val!=Qfalse && val!=Qtrue) { + rb_raise(rb_eTypeError, "The second argument must be true or false."); + return Qnil; /* Not reached */ + } if(f&VP_EXCEPTION_INFINITY) { VpSetException((unsigned short)((val==Qtrue)?(fo|VP_EXCEPTION_INFINITY): (fo&(~VP_EXCEPTION_INFINITY)))); @@ -248,14 +252,22 @@ BigDecimal_mode(VALUE self, VALUE which, VALUE val) VpSetException((unsigned short)((val==Qtrue)?(fo|VP_EXCEPTION_NaN): (fo&(~VP_EXCEPTION_NaN)))); } + fo = VpGetException(); return INT2FIX(fo); } if(VP_ROUND_MODE==f) { /* Rounding mode setting */ - if(TYPE(val)!=T_FIXNUM) return Qnil; + fo = VpGetRoundMode(); + if(val==Qnil) return INT2FIX(fo); + Check_Type(val, T_FIXNUM); + if(!VpIsRoundMode(FIX2INT(val))) { + rb_raise(rb_eTypeError, "Invalid rounding mode."); + return Qnil; + } fo = VpSetRoundMode((unsigned long)FIX2INT(val)); return INT2FIX(fo); } + rb_raise(rb_eTypeError, "The first argument for BigDecimal#mode is invalid."); return Qnil; } @@ -919,13 +931,14 @@ BigDecimal_round(int argc, VALUE *argv, VALUE self) Check_Type(vLoc, T_FIXNUM); iLoc = FIX2INT(vLoc); break; - case 2:{ - int sws = sw; + case 2: Check_Type(vLoc, T_FIXNUM); iLoc = FIX2INT(vLoc); Check_Type(vRound, T_FIXNUM); - sw = VpSetRoundMode(FIX2INT(vRound)); - VpSetRoundMode(sws); + sw = FIX2INT(vRound); + if(!VpIsRoundMode(sw)) { + rb_raise(rb_eTypeError, "Invalid rounding mode."); + return Qnil; } break; } @@ -1024,20 +1037,45 @@ static VALUE BigDecimal_to_s(int argc, VALUE *argv, VALUE self) { ENTER(5); - Real *vp; - char *psz; + int fmt=0; /* 0:E format */ + Real *vp; + char *psz; + char ch; U_LONG nc; - S_INT mc = 0; - VALUE f; + S_INT mc = 0; + VALUE f; GUARD_OBJ(vp,GetVpValue(self,1)); - nc = VpNumOfChars(vp)+1; + if(rb_scan_args(argc,argv,"01",&f)==1) { - mc = GetPositiveInt(f); - nc += (nc + mc - 1) / mc + 1; + if(TYPE(f)==T_STRING) { + SafeStringValue(f); + psz = RSTRING(f)->ptr; + while(ch=*psz++) { + if(!ISDIGIT(ch)) { + if(ch=='F' || ch=='f') fmt = 1; /* F format */ + break; + } + mc = mc * 10 + ch - '0'; + } + } else { + mc = GetPositiveInt(f); + } + if(fmt) { + nc = VpNumOfChars(vp,"F"); + } else { + nc = VpNumOfChars(vp,"E"); + } + if(mc>0) nc += (nc + mc - 1) / mc + 1; } + psz = ALLOCA_N(char,(unsigned int)nc); - VpToString(vp, psz, mc); + + if(fmt) { + VpToFString(vp, psz, mc); + } else { + VpToString (vp, psz, mc); + } return rb_str_new2(psz); } @@ -1052,7 +1090,7 @@ BigDecimal_split(VALUE self) char *psz1; GUARD_OBJ(vp,GetVpValue(self,1)); - psz1 = ALLOCA_N(char,(unsigned int)VpNumOfChars(vp)); + psz1 = ALLOCA_N(char,(unsigned int)VpNumOfChars(vp,"E")); VpSzMantissa(vp,psz1); s = 1; if(psz1[0]=='-') { @@ -1087,7 +1125,7 @@ BigDecimal_inspect(VALUE self) char *pszAll; GUARD_OBJ(vp,GetVpValue(self,1)); - nc = VpNumOfChars(vp); + nc = VpNumOfChars(vp,"E"); nc +=(nc + 9) / 10; psz1 = ALLOCA_N(char,nc); @@ -1298,7 +1336,7 @@ Init_bigdecimal(void) rb_define_const(rb_cBigDecimal, "SIGN_NEGATIVE_INFINITE",INT2FIX(VP_SIGN_NEGATIVE_INFINITE)); /* instance methods */ - rb_define_method(rb_cBigDecimal, "prec", BigDecimal_prec, 0); + rb_define_method(rb_cBigDecimal, "precs", BigDecimal_prec, 0); rb_define_method(rb_cBigDecimal, "add", BigDecimal_add2, 2); rb_define_method(rb_cBigDecimal, "sub", BigDecimal_sub2, 2); rb_define_method(rb_cBigDecimal, "mult", BigDecimal_mult2, 2); @@ -1478,14 +1516,21 @@ VpGetRoundMode(void) return gfRoundMode; } -VP_EXPORT unsigned long -VpSetRoundMode(unsigned long n) +VP_EXPORT int +VpIsRoundMode(unsigned long n) { if(n==VP_ROUND_UP || n!=VP_ROUND_DOWN || n==VP_ROUND_HALF_UP || n!=VP_ROUND_HALF_DOWN || n==VP_ROUND_CEIL || n!=VP_ROUND_FLOOR || n==VP_ROUND_HALF_EVEN - ) gfRoundMode = n; + ) return 1; + return 0; +} + +VP_EXPORT unsigned long +VpSetRoundMode(unsigned long n) +{ + if(VpIsRoundMode(n)) gfRoundMode = n; return gfRoundMode; } @@ -1630,13 +1675,13 @@ raise: static int VpIsDefOP(Real *c,Real *a,Real *b,int sw) { - if(VpIsNaN(a) || VpIsNaN(b)) { + if(VpIsNaN(a) || VpIsNaN(b)) { /* at least a or b is NaN */ VpSetNaN(c); goto NaN; - } + } - if(VpIsInf(a)) { + if(VpIsInf(a)) { if(VpIsInf(b)) { switch(sw) { @@ -1686,7 +1731,7 @@ VpIsDefOP(Real *c,Real *a,Real *b,int sw) VpSetInf(c,VpGetSign(a)*VpGetSign(b)); } goto Inf; - } + } if(VpIsInf(b)) { switch(sw) @@ -1722,14 +1767,35 @@ NaN: */ /* - * returns number of chars needed to represent vp. + * returns number of chars needed to represent vp in specified format. */ VP_EXPORT U_LONG -VpNumOfChars(Real *vp) +VpNumOfChars(Real *vp,char *pszFmt) { + S_INT ex; + U_LONG nc; + if(vp == NULL) return BASE_FIG*2+6; if(!VpIsDef(vp)) return 32; /* not sure,may be OK */ - return BASE_FIG *(vp->Prec + 2)+6; /* 3: sign + exponent chars */ + + switch(*pszFmt) + { + case 'F': + nc = BASE_FIG*(vp->Prec + 1)+2; + ex = vp->exponent; + if(ex<0) { + nc += BASE_FIG*(-ex); + } else { + if(ex > (S_INT)vp->Prec) { + nc += BASE_FIG*(ex - (S_INT)vp->Prec); + } + } + break; + case 'E': + default: + nc = BASE_FIG*(vp->Prec + 2)+6; /* 3: sign + exponent chars */ + } + return nc; } /* @@ -2110,10 +2176,10 @@ end_if: isw = VpGetSign(a) + sw *VpGetSign(b); /* * isw = 0 ...( 1)+(-1),( 1)-( 1),(-1)+(1),(-1)-(-1) - * = 2 ...( 1)+( 1),( 1)-(-1) - * =-2 ...(-1)+(-1),(-1)-( 1) + * = 2 ...( 1)+( 1),( 1)-(-1) + * =-2 ...(-1)+(-1),(-1)-( 1) * If isw==0, then c =(Sign a_ptr)(|a_ptr|-|b_ptr|) - * else c =(Sign of isw)(|a_ptr|+|b_ptr|) + * else c =(Sign ofisw)(|a_ptr|+|b_ptr|) */ if(isw) { /* addition */ VpSetSign(c,(S_INT)1); @@ -2363,12 +2429,12 @@ Exit: * a = xxxxxxxxxxx * b = xxxxxxxxxx * c =xxxxxxxxxxxxxxx - * word_shift = | | - * right_word = | | (Total digits in RHSV) - * left_word = | | (Total digits in LHSV) - * a_pos = | - * b_pos = | - * c_pos = | + * word_shift = | | + * right_word = | | (Total digits in RHSV) + * left_word = | | (Total digits in LHSV) + * a_pos = | + * b_pos = | + * c_pos = | */ static U_LONG VpSetPTR(Real *a, Real *b, Real *c, U_LONG *a_pos, U_LONG *b_pos, U_LONG *c_pos, U_LONG *av, U_LONG *bv) @@ -2381,17 +2447,17 @@ VpSetPTR(Real *a, Real *b, Real *c, U_LONG *a_pos, U_LONG *b_pos, U_LONG *c_pos, right_word = Max((a->Prec),left_word); left_word =(c->MaxPrec) - 1; /* -1 ... prepare for round up */ /* - * check if 'round off' is needed. + * check if 'round' is needed. */ - if(right_word > left_word) { /* round off ? */ + if(right_word > left_word) { /* round ? */ /*--------------------------------- * Actual size of a = xxxxxxAxx * Actual size of b = xxxBxxxxx * Max. size of c = xxxxxx - * Round off = |-----| - * c_pos = | - * right_word = | - * a_pos = | + * Round off = |-----| + * c_pos = | + * right_word = | + * a_pos = | */ *c_pos = right_word = left_word + 1; /* Set resulting precision */ /* be equal to that of c */ @@ -3036,7 +3102,8 @@ VpFormatSt(char *psz,S_INT fFmt) U_LONG i; S_INT nf = 0; char ch; - int fDot = 0; + + if(fFmt<=0) return; ie = strlen(psz); for(i = 0; i < ie; ++i) { @@ -3044,10 +3111,8 @@ VpFormatSt(char *psz,S_INT fFmt) if(!ch) break; if(ch == '.') { nf = 0; - fDot = 1; continue; } - if(!fDot) continue; if(ch == 'E') break; nf++; if(nf > fFmt) { @@ -3123,60 +3188,118 @@ VpSzMantissa(Real *a,char *psz) } } -VP_EXPORT void -VpToString(Real *a,char *psz,int fFmt) +VP_EXPORT int +VpToSpecialString(Real *a,char *psz) { - U_LONG i, ZeroSup; - U_LONG n, m, e, nn; - char *pszSav = psz; - S_LONG ex; - if(VpIsNaN(a)) { sprintf(psz,SZ_NaN); - return; + return 1; } if(VpIsPosInf(a)) { sprintf(psz,SZ_INF); - return; + return 1; } if(VpIsNegInf(a)) { sprintf(psz,SZ_NINF); - return; + return 1; } + if(VpIsZero(a)) { + if(VpIsPosZero(a)) sprintf(psz, "0.0"); + else sprintf(psz, "-0.0"); + return 1; + } + return 0; +} + +VP_EXPORT void +VpToString(Real *a,char *psz,int fFmt) +{ + U_LONG i, ZeroSup; + U_LONG n, m, e, nn; + char *pszSav = psz; + S_LONG ex; + + if(VpToSpecialString(a,psz)) return; ZeroSup = 1; /* Flag not to print the leading zeros as 0.00xxxxEnn */ - if(!VpIsZero(a)) { - if(VpGetSign(a) < 0) *psz++ = '-'; - *psz++ = '0'; - *psz++ = '.'; - n = a->Prec; - for(i=0;i < n;++i) { - m = BASE1; - e = a->frac[i]; - 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; + + if(VpGetSign(a) < 0) *psz++ = '-'; + *psz++ = '0'; + *psz++ = '.'; + n = a->Prec; + for(i=0;i < n;++i) { + m = BASE1; + e = a->frac[i]; + 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; - n = BASE1; - while((a->frac[0] / n) == 0) { - --ex; - n /= 10; - } - while(psz[-1]=='0') *(--psz) = 0; - sprintf(psz, "E%ld", ex); - } else { - if(VpIsPosZero(a)) sprintf(psz, "0.0"); - else sprintf(psz, "-0.0"); } + ex =(a->exponent) * BASE_FIG; + n = BASE1; + while((a->frac[0] / n) == 0) { + --ex; + n /= 10; + } + while(psz[-1]=='0') *(--psz) = 0; + sprintf(psz, "E%ld", ex); + if(fFmt) VpFormatSt(pszSav, fFmt); +} + +VP_EXPORT void +VpToFString(Real *a,char *psz,int fFmt) +{ + U_LONG i; + U_LONG n, m, e, nn; + char *pszSav = psz; + S_LONG ex; + + if(VpToSpecialString(a,psz)) return; + + if(VpGetSign(a) < 0) *psz++ = '-'; + n = a->Prec; + ex = a->exponent; + if(ex<=0) { + *psz++ = '0';*psz++ = '.'; + while(ex<0) { + for(i=0;i= 0) { + sprintf(psz, "%lu", a->frac[i]); + psz += strlen(psz); + } else { + m = BASE1; + e = a->frac[i]; + while(m) { + nn = e / m; + *psz++ = nn + '0'; + e = e - nn * m; + m /= 10; + } + } + if(ex == 0) *psz++ = '.'; + } + while(--ex>=0) { + m = BASE; + while(m/=10) *psz++ = '0'; + if(ex == 0) *psz++ = '.'; + } + *psz = 0; + while(psz[-1]=='0') *(--psz) = 0; + if(psz[-1]=='.') sprintf(psz, "0"); if(fFmt) VpFormatSt(pszSav, fFmt); } diff --git a/ext/bigdecimal/bigdecimal.h b/ext/bigdecimal/bigdecimal.h index 0af0b1dfc5..8230512e6a 100644 --- a/ext/bigdecimal/bigdecimal.h +++ b/ext/bigdecimal/bigdecimal.h @@ -122,12 +122,13 @@ VP_EXPORT U_LONG VpGetPrecLimit(void); VP_EXPORT U_LONG VpSetPrecLimit(U_LONG n); /* Round mode */ +VP_EXPORT int VpIsRoundMode(unsigned long n); VP_EXPORT unsigned long VpGetRoundMode(void); VP_EXPORT unsigned long VpSetRoundMode(unsigned long n); VP_EXPORT int VpException(unsigned short f,char *str,int always); VP_EXPORT int VpIsNegDoubleZero(double v); -VP_EXPORT U_LONG VpNumOfChars(Real *vp); +VP_EXPORT U_LONG VpNumOfChars(Real *vp,char *pszFmt); VP_EXPORT U_LONG VpInit(U_LONG BaseVal); VP_EXPORT void *VpMemAlloc(U_LONG mb); VP_EXPORT void VpFree(Real *pv); @@ -139,7 +140,9 @@ VP_EXPORT int VpDivd(Real *c,Real *r,Real *a,Real *b); VP_EXPORT int VpComp(Real *a,Real *b); VP_EXPORT S_LONG VpExponent10(Real *a); VP_EXPORT void VpSzMantissa(Real *a,char *psz); +VP_EXPORT int VpToSpecialString(Real *a,char *psz); VP_EXPORT void VpToString(Real *a,char *psz,int fFmt); +VP_EXPORT void VpToFString(Real *a,char *psz,int fFmt); VP_EXPORT int VpCtoV(Real *a,char *int_chr,U_LONG ni,char *frac,U_LONG nf,char *exp_chr,U_LONG ne); VP_EXPORT int VpVtoD(double *d,S_LONG *e,Real *m); VP_EXPORT void VpDtoV(Real *m,double d); diff --git a/ext/bigdecimal/bigdecimal_en.html b/ext/bigdecimal/bigdecimal_en.html index a8ced21e01..c4ed6b4c01 100644 --- a/ext/bigdecimal/bigdecimal_en.html +++ b/ext/bigdecimal/bigdecimal_en.html @@ -148,8 +148,8 @@ EXCEPTION_ZERODIVIDE results to +Infinity or -Infinity
EXCEPTION_INFINITY,EXCEPTION_OVERFLOW, and EXCEPTION_ZERODIVIDE are currently the same.
-The return value of mode method is the previous value set.
-nil is returned if any argument is wrong.
+The return value of mode method is the value set.
+If nil is specified for the second argument,then current setting is returned.
Suppose the return value of the mode method is f,then f & BigDecimal::EXCEPTION_NaN !=0 means EXCEPTION_NaN is set to on.

@@ -169,8 +169,7 @@ where flag must be one of: ROUND_CEILINGround towards positive infinity(ceil). ROUND_FLOORround towards negative infinity(floor). -New rounding mode is returned,nil is returned if any argument is not an integer. -Bad specification is ignored.
+New rounding mode is returned. If nil is specified for the second argument,then current setting is returned.
The digit location for rounding operation can not be specified by this mode method, use truncate/round/ceil/floor/add/sub/mult/div mthods for each instance instead. @@ -359,10 +358,27 @@ If a is Infinity or NaN,then i becomes to nil.

  • to_s[(n)]
  • -converts to string(results look like "0.xxxxxEn").
    -s = a.to_s
    -If n is given,then a space is inserted after every n digits for readability.
    -s = a.to_s(n) +converts to string(default results look like "0.xxxxxEn"). +
    +BigDecimal("1.23456").to_s  #  ==> "0.123456E1"
    +
    +If n(>0) is given,then a space is inserted to each of two parts divided by the decimal point +after every n digits for readability. +
    +BigDecimal("0.1234567890123456789").to_s(10)   #  ==> "0.1234567890 123456789E0"
    +
    +n can be an string representing a positive integer number. +
    +BigDecimal("0.1234567890123456789").to_s("10") #  ==> "0.1234567890 123456789E0"
    +
    +At the end of the string,'E'(or 'e') or 'F'(or 'f') can be specified to change +number representation. +
    +BigDecimal("1234567890.123456789").to_s("E")  #  ==> "0.1234567890123456789E10"
    +BigDecimal("1234567890.123456789").to_s("F")  #  ==> "1234567890.123456789"
    +BigDecimal("1234567890.123456789").to_s("5E") #  ==> "0.12345 67890 12345 6789E10"
    +BigDecimal("1234567890.123456789").to_s("5F") #  ==> "12345 67890.12345 6789"
    +
  • exponent
  • @@ -371,8 +387,8 @@ n = a.exponent
    means a = 0.xxxxxxx*10**n.
    -
  • prec
  • -n,m = a.prec
    +
  • precs
  • +n,m = a.precs
    prec returns number of significant digits (n) and maximum number of significant digits (m) of a.
    diff --git a/ext/bigdecimal/bigdecimal_ja.html b/ext/bigdecimal/bigdecimal_ja.html index 4fc3a4eb84..a59d61a838 100644 --- a/ext/bigdecimal/bigdecimal_ja.html +++ b/ext/bigdecimal/bigdecimal_ja.html @@ -157,10 +157,10 @@ EXCEPTION_ZERODIVIDE
    EXCEPTION_INFINITY�AEXCEPTION_OVERFLOW�AEXCEPTION_ZERODIVIDE �͍��̂Ƃ��듯���ł��B
    -�߂�l�́A�ݒ�O�̒l�ł��B�u�l�v�̈Ӗ��́A�Ⴆ�� +�߂�l�́A�ݒ��̒l�ł��B�u�l�v�̈Ӗ��́A�Ⴆ�� BigDecimal::EXCEPTION_NaN�Ɓu�l�v�� & �� �[���ȊO�Ȃ�� EXCEPTION_NaN���ݒ肳��Ă���Ƃ����Ӗ��ł��B
    -�����ɐ������Ȃ����̂��w�肳�ꂽ�ꍇ�� nil ���Ԃ�܂��B +��Q������ nil ���w�肷��ƁA����̐ݒ�l���Ԃ�܂��B

    [�ۂߏ����w��]

    @@ -181,8 +181,7 @@ f = BigDecimal::mode(BigDecimal::ROUND_MODE,flag) �߂�l�͎w���� flag �̒l�ł��B -�����ɐ��l�ȊO���w�肳�ꂽ�ꍇ�� nil ���Ԃ�܂��B�������Ȃ� ROUND_MODE ���w�肳�ꂽ�Ƃ��� -��������A����� ROUND_MODE ���Ԃ�܂��B
    +��Q������ nil ���w�肷��ƁA����̐ݒ�l���Ԃ�܂��B mode ���\�b�h�ł͊ۂߑ���̈ʒu�����[�U���w�肷�邱�Ƃ͂ł��܂���B �ۂߑ���ƈʒu�������Ő��䂵�����ꍇ�� truncate/round/ceil/floor �� add/sub/mult/div �Ƃ������C���X�^���X���\�b�h���g�p���ĉ������B @@ -375,10 +374,28 @@ Float ���������B

  • to_s[(n)]
  • -������ɕϊ����܂�("0.xxxxxEn"�̌`�ɂȂ�܂��j�B
    -s = a.to_s
    -n ���w�肳�ꂽ�Ƃ��́A���������� n �����ɋ󔒂ŋ�؂�܂��B
    -s = a.to_s(n) +������ɕϊ����܂�(�f�t�H���g�� "0.xxxxxEn" �̌`�ɂȂ�܂��j�B +
    +BigDecimal("1.23456").to_s  #  ==> "0.123456E1"
    +
    +���� n �ɐ��̐������w�肳�ꂽ�Ƃ��́A�����_�ŕ������鍶�E�������A���ꂼ�� n ���� +�ɋ󔒂ŋ�؂�܂��B +
    +BigDecimal("0.1234567890123456789").to_s(10)   #  ==> "0.1234567890 123456789E0"
    +
    +���� n �ɐ��̐�����\����������w�肷�邱�Ƃ��ł��܂��B +
    +BigDecimal("0.1234567890123456789").to_s("10") #  ==> "0.1234567890 123456789E0"
    +
    +����ɕ�����̍Ō�� E(�܂��� e) �� F(�܂��� f) ���w�肷�邱�ƂŁA�ȉ��̂悤�� +�\���`����ύX���邱�Ƃ��ł��܂��B +
    +BigDecimal("1234567890.123456789").to_s("E")  #  ==> "0.1234567890123456789E10"
    +BigDecimal("1234567890.123456789").to_s("F")  #  ==> "1234567890.123456789"
    +BigDecimal("1234567890.123456789").to_s("5E") #  ==> "0.12345 67890 12345 6789E10"
    +BigDecimal("1234567890.123456789").to_s("5F") #  ==> "12345 67890.12345 6789"
    +
    +
  • exponent
  • �w�����𐮐��l�ŕԂ��܂��B @@ -386,8 +403,8 @@ n = a.exponent
    �� a �̒l�� 0.xxxxxxx*10**n ���Ӗ����܂��B
    -
  • prec
  • -n,m = a.prec
    +
  • precs
  • +n,m = a.precs
    a �̗L������ (n) �ƍő�L������ (m) �̔z���Ԃ��܂��B
    -- cgit v1.2.3