summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro Matz Matsumoto <[email protected]>2012-11-21 17:01:09 +0900
committerYukihiro Matz Matsumoto <[email protected]>2012-11-21 17:01:09 +0900
commitae6a7e5aae115a417fd764fd3160b7df48df9631 (patch)
tree02c4bb731078ef2f26d90706cb220c67d73fe939
parent76f0e755e92d845b4b4bac1d77aa5eeb42bbbec9 (diff)
parent8894cbe00f6202e2088000d2a3e7553fa7730bad (diff)
downloadmruby-ae6a7e5aae115a417fd764fd3160b7df48df9631.tar.gz
mruby-ae6a7e5aae115a417fd764fd3160b7df48df9631.zip
Merge branch 'master' of github.com:mruby/mruby
-rw-r--r--src/class.c1
-rw-r--r--src/math.c5
-rw-r--r--test/t/math.rb8
3 files changed, 12 insertions, 2 deletions
diff --git a/src/class.c b/src/class.c
index d95a05789..fe2baa4f2 100644
--- a/src/class.c
+++ b/src/class.c
@@ -1400,6 +1400,7 @@ mrb_init_class(mrb_state *mrb)
make_metaclass(mrb, cls);
/* name basic classes */
+ mrb_define_const(mrb, bob, "BasicObject", mrb_obj_value(bob));
mrb_define_const(mrb, obj, "BasicObject", mrb_obj_value(bob));
mrb_define_const(mrb, obj, "Object", mrb_obj_value(obj));
mrb_define_const(mrb, obj, "Module", mrb_obj_value(mod));
diff --git a/src/math.c b/src/math.c
index 9aae87acd..3e4550946 100644
--- a/src/math.c
+++ b/src/math.c
@@ -51,7 +51,7 @@ erf(double x)
term *= xsqr/j;
sum += term/(2*j+1);
++j;
- } while (fabs(term)/sum > MATH_TOLERANCE);
+ } while (fabs(term/sum) > MATH_TOLERANCE);
return two_sqrtpi*sum;
}
@@ -64,7 +64,8 @@ erfc(double x)
double b = x;
double c = x;
double d = x*x+0.5;
- double q1, q2;
+ double q1;
+ double q2 = b/d;
double n = 1.0;
double t;
if (fabs(x) < 2.2) {
diff --git a/test/t/math.rb b/test/t/math.rb
index d71e44fc9..780b805d2 100644
--- a/test/t/math.rb
+++ b/test/t/math.rb
@@ -113,5 +113,13 @@ if Object.const_defined?(:Math)
assert('Math.erfc 1') do
check_float(Math.erfc(1), 0.157299207050285)
end
+
+ assert('Math.erf -1') do
+ check_float(Math.erf(-1), -0.8427007929497148)
+ end
+
+ assert('Math.erfc -1') do
+ check_float(Math.erfc(-1), 1.8427007929497148)
+ end
end