mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
stop introducing Math::TORELANCE
This commit is contained in:
+3
-3
@@ -10,10 +10,11 @@
|
||||
#define domain_error(msg) \
|
||||
mrb_raise(mrb, E_RANGE_ERROR, "Numerical argument is out of domain - " #msg);
|
||||
|
||||
#define MATH_TOLERANCE 1E-12
|
||||
|
||||
/* math functions not provided under Microsoft Visual C++ */
|
||||
#ifdef _MSC_VER
|
||||
|
||||
#define MATH_TOLERANCE 1E-12
|
||||
|
||||
#define asinh(x) log(x + sqrt(pow(x,2.0) + 1))
|
||||
#define acosh(x) log(x + sqrt(pow(x,2.0) - 1))
|
||||
#define atanh(x) (log(1+x) - log(1-x))/2.0
|
||||
@@ -631,7 +632,6 @@ mrb_init_math(mrb_state *mrb)
|
||||
struct RClass *mrb_math;
|
||||
mrb_math = mrb_define_module(mrb, "Math");
|
||||
|
||||
mrb_define_const(mrb, mrb_math, "TOLERANCE", mrb_float_value(MATH_TOLERANCE));
|
||||
#ifdef M_PI
|
||||
mrb_define_const(mrb, mrb_math, "PI", mrb_float_value(M_PI));
|
||||
#else
|
||||
|
||||
+2
-2
@@ -74,12 +74,12 @@ end
|
||||
# Performs fuzzy check for equality on methods returning floats
|
||||
# on the basis of the Math::TOLERANCE constant.
|
||||
def check_float(a, b)
|
||||
tolerance = 1e-12
|
||||
a = a.to_f
|
||||
b = b.to_f
|
||||
if a.finite? and b.finite?
|
||||
(a-b).abs < Math::TOLERANCE
|
||||
(a-b).abs < tolerance
|
||||
else
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user