summaryrefslogtreecommitdiff
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
commitb160d23c68e2e8fcd82b96fab0977be11c2b9ec6 (patch)
treed85dbe40e1b2ff4089f4c4f228e65e2eb09243b5 /math.c
parenta424741c8e73bbca5d893594abbdfda489794739 (diff)
* math.c (math_cbrt): new method Math.cbrt.
* configure.in (cbrt): check for replacement functions. * missing/cbrt.c: new file. git-svn-id: svn+ssh://ci.ruby-lang.org/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 fd10e97..1f78d98 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);