summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-11-30 09:24:26 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-11-30 09:24:26 +0000
commita3b6b11a8bd51fd0bca9f47f4f25fc37afc3c5c2 (patch)
treef7e9c3bd4f306ab4a93d1350eb62fe7c27d5d75c /ext
parent9db194227f41b824d15a93e0d2020ec72a5c1c33 (diff)
merges r20366 from trunk into ruby_1_9_1.
* ext/bigdecimal/bigdecimal.c (VpException): bigdecimal zero division should raise FloatDomainError if mode VP_EXCEPTION_ZERODIVIDE is set. [ruby-dev:37204] * ext/bigdecimal/bigdecimal.c (BigDecimal_mode): should handle VP_EXCEPTION_ZERODIVIDE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@20420 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/bigdecimal/bigdecimal.c13
-rw-r--r--ext/bigdecimal/bigdecimal.h2
2 files changed, 7 insertions, 8 deletions
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index 66ab12bca6..0a43570903 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -425,6 +425,11 @@ BigDecimal_mode(int argc, VALUE *argv, VALUE self)
(fo&(~VP_EXCEPTION_UNDERFLOW))));
}
fo = VpGetException();
+ if(f&VP_EXCEPTION_ZERODIVIDE) {
+ VpSetException((unsigned short)((val==Qtrue)?(fo|VP_EXCEPTION_ZERODIVIDE):
+ (fo&(~VP_EXCEPTION_ZERODIVIDE))));
+ }
+ fo = VpGetException();
return INT2FIX(fo);
}
if(VP_ROUND_MODE==f) {
@@ -2270,18 +2275,12 @@ VpException(unsigned short f, const char *str,int always)
switch(f)
{
/*
- case VP_EXCEPTION_ZERODIVIDE:
case VP_EXCEPTION_OVERFLOW:
*/
+ case VP_EXCEPTION_ZERODIVIDE:
case VP_EXCEPTION_INFINITY:
- exc = rb_eFloatDomainError;
- goto raise;
case VP_EXCEPTION_NaN:
- exc = rb_eFloatDomainError;
- goto raise;
case VP_EXCEPTION_UNDERFLOW:
- exc = rb_eFloatDomainError;
- goto raise;
case VP_EXCEPTION_OP:
exc = rb_eFloatDomainError;
goto raise;
diff --git a/ext/bigdecimal/bigdecimal.h b/ext/bigdecimal/bigdecimal.h
index 3a300f1df5..a30a08e615 100644
--- a/ext/bigdecimal/bigdecimal.h
+++ b/ext/bigdecimal/bigdecimal.h
@@ -45,7 +45,7 @@ extern "C" {
#define VP_EXCEPTION_NaN ((unsigned short)0x0002)
#define VP_EXCEPTION_UNDERFLOW ((unsigned short)0x0004)
#define VP_EXCEPTION_OVERFLOW ((unsigned short)0x0001) /* 0x0008) */
-#define VP_EXCEPTION_ZERODIVIDE ((unsigned short)0x0001) /* 0x0010) */
+#define VP_EXCEPTION_ZERODIVIDE ((unsigned short)0x0010)
/* Following 2 exceptions cann't controlled by user */
#define VP_EXCEPTION_OP ((unsigned short)0x0020)