diff options
| author | Yukihiro Matsumoto <[email protected]> | 2012-06-14 00:41:33 +0900 |
|---|---|---|
| committer | Yukihiro Matsumoto <[email protected]> | 2012-06-14 00:41:33 +0900 |
| commit | 91a665905a8781373480f003c2e15cef9fa3604c (patch) | |
| tree | 6d23cf58c8aba4fcd40c229cd0212ccc8bf9afaa | |
| parent | e2447d3530eb16ac343771b64ec5b1e59670a715 (diff) | |
| download | mruby-91a665905a8781373480f003c2e15cef9fa3604c.tar.gz mruby-91a665905a8781373480f003c2e15cef9fa3604c.zip | |
Math.log to take optinal second argument
| -rw-r--r-- | src/math.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/math.c b/src/math.c index 48180a98f..1de9c0d8f 100644 --- a/src/math.c +++ b/src/math.c @@ -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); } |
