summaryrefslogtreecommitdiffstats
path: root/math.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-02-09 09:36:03 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-02-09 09:36:03 +0000
commit759833538095fcd3096bb8dd8a5391688537f8b0 (patch)
treed85dbe40e1b2ff4089f4c4f228e65e2eb09243b5 /math.c
parent9cd046263812edd9d7c10c5f52d82a9d41ffc7da (diff)
downloadruby-759833538095fcd3096bb8dd8a5391688537f8b0.tar.gz
ruby-759833538095fcd3096bb8dd8a5391688537f8b0.tar.xz
ruby-759833538095fcd3096bb8dd8a5391688537f8b0.zip
* math.c (math_cbrt): new method Math.cbrt.
* configure.in (cbrt): check for replacement functions. * missing/cbrt.c: new file. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@15416 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'math.c')
-rw-r--r--math.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/math.c b/math.c
index fd10e9700..1f78d98a5 100644
--- a/math.c
+++ b/math.c
@@ -402,6 +402,20 @@ math_sqrt(VALUE obj, VALUE x)
/*
* call-seq:
+ * Math.cbrt(numeric) => float
+ *
+ * Returns the cube root of <i>numeric</i>.
+ */
+
+static VALUE
+math_cbrt(VALUE obj, VALUE x)
+{
+ Need_Float(x);
+ return DOUBLE2NUM(cbrt(RFLOAT_VALUE(x)));
+}
+
+/*
+ * call-seq:
* Math.frexp(numeric) => [ fraction, exponent ]
*
* Returns a two-element array containing the normalized fraction (a
@@ -611,6 +625,7 @@ Init_Math(void)
rb_define_module_function(rb_mMath, "log2", math_log2, 1);
rb_define_module_function(rb_mMath, "log10", math_log10, 1);
rb_define_module_function(rb_mMath, "sqrt", math_sqrt, 1);
+ rb_define_module_function(rb_mMath, "cbrt", math_cbrt, 1);
rb_define_module_function(rb_mMath, "frexp", math_frexp, 1);
rb_define_module_function(rb_mMath, "ldexp", math_ldexp, 2);