mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Math.log to take optinal second argument
This commit is contained in:
+6
-3
@@ -411,11 +411,14 @@ math_exp(mrb_state *mrb, mrb_value obj)
|
||||
static mrb_value
|
||||
math_log(mrb_state *mrb, mrb_value obj)
|
||||
{
|
||||
mrb_float x;
|
||||
mrb_float x, base;
|
||||
int argc;
|
||||
|
||||
mrb_get_args(mrb, "f", &x);
|
||||
argc = mrb_get_args(mrb, "f|f", &x, &base);
|
||||
x = log(x);
|
||||
|
||||
if (argc == 2) {
|
||||
d /= log(base);
|
||||
}
|
||||
return mrb_float_value(x);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user