summaryrefslogtreecommitdiff
path: root/math.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-09-03 09:00:52 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-09-03 09:00:52 +0000
commit880d7af47a66f021712eac17adffac2686d08aad (patch)
tree71f148de518815dc3548c36896ad0ad142e9015a /math.c
parent7cf8256075020e1dd80800807e3d92f3350511e6 (diff)
* struct.c (make_struct): remove redefining constant when
conflict. [ruby-dev:24210] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6854 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'math.c')
-rw-r--r--math.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/math.c b/math.c
index 5b9294e..cea7bb8 100644
--- a/math.c
+++ b/math.c
@@ -333,6 +333,28 @@ math_log(obj, x)
/*
* call-seq:
+ * Math.log2(numeric) => float
+ *
+ * Returns the base 2 logarithm of <i>numeric</i>.
+ */
+
+static VALUE
+math_log2(obj, x)
+ VALUE obj, x;
+{
+ double d;
+
+ Need_Float(x);
+ errno = 0;
+ d = log2(RFLOAT(x)->value);
+ if (errno) {
+ rb_sys_fail("log2");
+ }
+ return rb_float_new(d);
+}
+
+/*
+ * call-seq:
* Math.log10(numeric) => float
*
* Returns the base 10 logarithm of <i>numeric</i>.
@@ -511,6 +533,7 @@ Init_Math()
rb_define_module_function(rb_mMath, "exp", math_exp, 1);
rb_define_module_function(rb_mMath, "log", math_log, 1);
+ rb_define_module_function(rb_mMath, "log2", math_log, 1);
rb_define_module_function(rb_mMath, "log10", math_log10, 1);
rb_define_module_function(rb_mMath, "sqrt", math_sqrt, 1);