summaryrefslogtreecommitdiff
path: root/math.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-06-05 09:54:09 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-06-05 09:54:09 +0000
commit7c3537f27dd9edd5c8ff3cfa4aa2748abd975f44 (patch)
tree647231dfe35094f595a140da388995c4223e9fc3 /math.c
parent605ac74db3dc94edba2799e18dd1b3a6f360dcb6 (diff)
* math.c (Init_Math): backport asin, acos, atan.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@2525 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'math.c')
-rw-r--r--math.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/math.c b/math.c
index 2cac83e938..86c889dca9 100644
--- a/math.c
+++ b/math.c
@@ -57,6 +57,39 @@ math_tan(obj, x)
}
static VALUE
+math_acos(obj, x)
+ VALUE obj, x;
+{
+ Need_Float(x);
+ /*
+ if (RFLOAT(x)->value < -1.0 || RFLOAT(x)->value > 1.0)
+ rb_raise(rb_eArgError, "Out of range (-1..1)");
+ */
+ return rb_float_new(acos(RFLOAT(x)->value));
+}
+
+static VALUE
+math_asin(obj, x)
+ VALUE obj, x;
+{
+ Need_Float(x);
+ /*
+ if (RFLOAT(x)->value < -1.0 || RFLOAT(x)->value > 1.0)
+ rb_raise(rb_eArgError, "Out of range (-1..1)");
+ */
+ return rb_float_new(asin(RFLOAT(x)->value));
+}
+
+static VALUE
+math_atan(obj, x)
+ VALUE obj, x;
+{
+ Need_Float(x);
+
+ return rb_float_new(atan(RFLOAT(x)->value));
+}
+
+static VALUE
math_exp(obj, x)
VALUE obj, x;
{
@@ -140,6 +173,10 @@ Init_Math()
rb_define_module_function(rb_mMath, "sin", math_sin, 1);
rb_define_module_function(rb_mMath, "tan", math_tan, 1);
+ rb_define_module_function(rb_mMath, "acos", math_acos, 1);
+ rb_define_module_function(rb_mMath, "asin", math_asin, 1);
+ rb_define_module_function(rb_mMath, "atan", math_atan, 1);
+
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, "log10", math_log10, 1);