diff options
Diffstat (limited to 'src/math.c')
| -rw-r--r-- | src/math.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/math.c b/src/math.c index 519d4f37b..fe10848c3 100644 --- a/src/math.c +++ b/src/math.c @@ -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)); |
