ruby-changes:12092
From: yugui <ko1@a...>
Date: Sat, 20 Jun 2009 18:08:30 +0900 (JST)
Subject: [ruby-changes:12092] Ruby:r23765 (ruby_1_9_1): merges r23609 from trunk into ruby_1_9_1.
yugui 2009-06-20 18:07:57 +0900 (Sat, 20 Jun 2009) New Revision: 23765 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=23765 Log: merges r23609 from trunk into ruby_1_9_1. -- * ext/bigdecimal/bigdecimal.c (BigDecimal_to_f): returns Inf if exp is bigger than DBL_MANT_DIG. Modified files: branches/ruby_1_9_1/ChangeLog branches/ruby_1_9_1/ext/bigdecimal/bigdecimal.c branches/ruby_1_9_1/version.h Index: ruby_1_9_1/ChangeLog =================================================================== --- ruby_1_9_1/ChangeLog (revision 23764) +++ ruby_1_9_1/ChangeLog (revision 23765) @@ -1,3 +1,8 @@ +Mon Jun 1 07:20:02 2009 Yukihiro Matsumoto <matz@r...> + + * ext/bigdecimal/bigdecimal.c (BigDecimal_to_f): returns Inf if + exp is bigger than DBL_MANT_DIG. + Sun May 31 23:26:36 2009 Nobuyoshi Nakada <nobu@r...> * file.c (istrailinggarbage): fixed typo. Index: ruby_1_9_1/ext/bigdecimal/bigdecimal.c =================================================================== --- ruby_1_9_1/ext/bigdecimal/bigdecimal.c (revision 23764) +++ ruby_1_9_1/ext/bigdecimal/bigdecimal.c (revision 23765) @@ -604,16 +604,18 @@ volatile VALUE str; GUARD_OBJ(p,GetVpValue(self,1)); - if(VpVtoD(&d, &e, p)!=1) return rb_float_new(d); + if (VpVtoD(&d, &e, p)!=1) return rb_float_new(d); + if (e > DBL_MAX_10_EXP) goto erange; str = rb_str_new(0, VpNumOfChars(p,"E")); buf = RSTRING_PTR(str); VpToString(p, buf, 0, 0); errno = 0; d = strtod(buf, 0); if(errno == ERANGE) { + erange: VpException(VP_EXCEPTION_OVERFLOW,"BigDecimal to Float conversion",0); - if(d>0.0) return rb_float_new(DBL_MAX); - else return rb_float_new(-DBL_MAX); + if(d>0.0) d = VpGetDoublePosInf(); + else d = VpGetDoubleNegInf(); } return rb_float_new(d); } Index: ruby_1_9_1/version.h =================================================================== --- ruby_1_9_1/version.h (revision 23764) +++ ruby_1_9_1/version.h (revision 23765) @@ -1,6 +1,6 @@ #define RUBY_VERSION "1.9.1" #define RUBY_RELEASE_DATE "2009-05-22" -#define RUBY_PATCHLEVEL 163 +#define RUBY_PATCHLEVEL 164 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 9 #define RUBY_VERSION_TEENY 1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/