From d9227aa41d8e626e7ff706f2d8cb94fea08658a9 Mon Sep 17 00:00:00 2001 From: Yukihiro Matsumoto Date: Thu, 24 May 2012 21:10:23 +0900 Subject: remove ZeroDivisionError since mruby gives float for integer division --- src/error.c | 2 +- src/numeric.c | 26 -------------------------- 2 files changed, 1 insertion(+), 27 deletions(-) diff --git a/src/error.c b/src/error.c index 5b32e3a00..feaa04af7 100644 --- a/src/error.c +++ b/src/error.c @@ -443,7 +443,7 @@ mrb_init_exception(mrb_state *mrb) #ifdef INCLUDE_ENCODING mrb_define_class(mrb, "EncodingError", mrb->eStandardError_class); #endif - mrb_define_class(mrb, "ZeroDivisionError", mrb->eStandardError_class); /* 15.2.30 */ + // mrb_define_class(mrb, "ZeroDivisionError", mrb->eStandardError_class); /* 15.2.30 */ mrb_define_class(mrb, "FloatDomainError", eRangeError); mrb_define_class(mrb, "KeyError", eIndexError); diff --git a/src/numeric.c b/src/numeric.c index 09d55a5de..f26dda424 100644 --- a/src/numeric.c +++ b/src/numeric.c @@ -37,12 +37,6 @@ #define fmod(x,y) fmodf(x,y) #endif -void -mrb_num_zerodiv(mrb_state *mrb) -{ - mrb_raise(mrb, E_ZERODIVISION_ERROR, "divided by 0"); -} - static mrb_float mrb_to_flo(mrb_state *mrb, mrb_value val) { @@ -252,7 +246,6 @@ flodivmod(mrb_state *mrb, mrb_float x, mrb_float y, mrb_float *divp, mrb_float * { mrb_float div, mod; - if (y == 0.0) mrb_num_zerodiv(mrb); mod = fmod(x, y); if (isinf(x) && !isinf(y) && !isnan(y)) div = x; @@ -744,7 +737,6 @@ fixdivmod(mrb_state *mrb, mrb_int x, mrb_int y, mrb_int *divp, mrb_int *modp) { mrb_int div, mod; - if (y == 0) mrb_num_zerodiv(mrb); if (y < 0) { if (x < 0) div = -x / -y; @@ -1042,24 +1034,6 @@ fix_to_f(mrb_state *mrb, mrb_value num) return mrb_float_value(val); } -/* - * Document-class: ZeroDivisionError - * - * Raised when attempting to divide an integer by 0. - * - * 42 / 0 - * - * raises the exception: - * - * ZeroDivisionError: divided by 0 - * - * Note that only division by an exact 0 will raise that exception: - * - * 42 / 0.0 #=> Float::INFINITY - * 42 / -0.0 #=> -Float::INFINITY - * 0 / 0.0 #=> NaN - */ - /* * Document-class: FloatDomainError * -- cgit v1.2.3