mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
add Math::TOLERANCE
This commit is contained in:
+17
-11
@@ -634,18 +634,24 @@ mrb_init_math(mrb_state *mrb)
|
||||
struct RClass *mrb_math;
|
||||
mrb_math = mrb_define_module(mrb, "Math");
|
||||
|
||||
#ifdef M_PI
|
||||
mrb_define_const(mrb, mrb_math, "PI", mrb_float_value(M_PI));
|
||||
#else
|
||||
mrb_define_const(mrb, mrb_math, "PI", mrb_float_value(atan(1.0)*4.0));
|
||||
#endif
|
||||
|
||||
#ifdef M_E
|
||||
mrb_define_const(mrb, mrb_math, "E", mrb_float_value(M_E));
|
||||
#else
|
||||
mrb_define_const(mrb, mrb_math, "E", mrb_float_value(exp(1.0)));
|
||||
#endif
|
||||
#ifdef M_PI
|
||||
mrb_define_const(mrb, mrb_math, "PI", mrb_float_value(M_PI));
|
||||
#else
|
||||
mrb_define_const(mrb, mrb_math, "PI", mrb_float_value(atan(1.0)*4.0));
|
||||
#endif
|
||||
|
||||
#ifdef M_E
|
||||
mrb_define_const(mrb, mrb_math, "E", mrb_float_value(M_E));
|
||||
#else
|
||||
mrb_define_const(mrb, mrb_math, "E", mrb_float_value(exp(1.0)));
|
||||
#endif
|
||||
|
||||
#ifdef MRB_USE_FLOAT
|
||||
mrb_define_const(mrb, mrb_math, "TOLERANCE", mrb_float_value(1e-6));
|
||||
#else
|
||||
mrb_define_const(mrb, mrb_math, "TOLERANCE", mrb_float_value(1e-12));
|
||||
#endif
|
||||
|
||||
mrb_define_module_function(mrb, mrb_math, "sin", math_sin, ARGS_REQ(1));
|
||||
mrb_define_module_function(mrb, mrb_math, "cos", math_cos, ARGS_REQ(1));
|
||||
mrb_define_module_function(mrb, mrb_math, "tan", math_tan, ARGS_REQ(1));
|
||||
|
||||
Reference in New Issue
Block a user