summaryrefslogtreecommitdiffhomepage
path: root/src/math.c
diff options
context:
space:
mode:
authorYukihiro Matsumoto <[email protected]>2012-06-14 00:41:33 +0900
committerYukihiro Matsumoto <[email protected]>2012-06-14 00:41:33 +0900
commit91a665905a8781373480f003c2e15cef9fa3604c (patch)
tree6d23cf58c8aba4fcd40c229cd0212ccc8bf9afaa /src/math.c
parente2447d3530eb16ac343771b64ec5b1e59670a715 (diff)
downloadmruby-91a665905a8781373480f003c2e15cef9fa3604c.tar.gz
mruby-91a665905a8781373480f003c2e15cef9fa3604c.zip
Math.log to take optinal second argument
Diffstat (limited to 'src/math.c')
-rw-r--r--src/math.c9
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);
}