diff options
| author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-02-09 09:36:03 +0000 |
|---|---|---|
| committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-02-09 09:36:03 +0000 |
| commit | 759833538095fcd3096bb8dd8a5391688537f8b0 (patch) | |
| tree | d85dbe40e1b2ff4089f4c4f228e65e2eb09243b5 /math.c | |
| parent | 9cd046263812edd9d7c10c5f52d82a9d41ffc7da (diff) | |
| download | ruby-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.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -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); |
