summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-06-20 09:07:57 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-06-20 09:07:57 +0000
commit33b5635a51196a5767b56d5a32556b96a31dc5b5 (patch)
tree55d379bf5a0a13efe165ea00e569677cc4349321
parent5784b103078be234267e001a3810e853389fcc6e (diff)
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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@23765 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--ext/bigdecimal/bigdecimal.c8
-rw-r--r--version.h2
3 files changed, 11 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index faa473b091..cc4fa3a03c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Mon Jun 1 07:20:02 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * 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@ruby-lang.org>
* file.c (istrailinggarbage): fixed typo.
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index 3472970fd5..061ec088ea 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -604,16 +604,18 @@ BigDecimal_to_f(VALUE self)
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);
}
diff --git a/version.h b/version.h
index ef50335eca..e24d04031e 100644
--- a/version.h
+++ b/version.h
@@ -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