diff options
author | (no author) <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-09-08 07:09:52 +0000 |
---|---|---|
committer | (no author) <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-09-08 07:09:52 +0000 |
commit | b1f96af92f5b8519c477de3bd8917e5220442f6b (patch) | |
tree | c29d1f6370f4498547c80a69e0440256eeaf39e7 /math.c | |
parent | 48acbc5e03622f1eb0423a6c2a3a603f61acfac6 (diff) |
This commit was manufactured by cvs2svn to create tag 'v1_1d-start'.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_1d-start@299 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'math.c')
-rw-r--r-- | math.c | 54 |
1 files changed, 27 insertions, 27 deletions
@@ -13,7 +13,7 @@ #include "ruby.h" #include <math.h> -VALUE mMath; +VALUE rb_mMath; #define Need_Float(x) (x) = rb_Float(x) #define Need_Float2(x,y) {\ @@ -26,7 +26,7 @@ math_atan2(obj, x, y) VALUE obj, x, y; { Need_Float2(x, y); - return float_new(atan2(RFLOAT(x)->value, RFLOAT(y)->value)); + return rb_float_new(atan2(RFLOAT(x)->value, RFLOAT(y)->value)); } static VALUE @@ -35,7 +35,7 @@ math_cos(obj, x) { Need_Float(x); - return float_new(cos(RFLOAT(x)->value)); + return rb_float_new(cos(RFLOAT(x)->value)); } static VALUE @@ -44,7 +44,7 @@ math_sin(obj, x) { Need_Float(x); - return float_new(sin(RFLOAT(x)->value)); + return rb_float_new(sin(RFLOAT(x)->value)); } static VALUE @@ -53,7 +53,7 @@ math_tan(obj, x) { Need_Float(x); - return float_new(tan(RFLOAT(x)->value)); + return rb_float_new(tan(RFLOAT(x)->value)); } static VALUE @@ -61,7 +61,7 @@ math_exp(obj, x) VALUE obj, x; { Need_Float(x); - return float_new(exp(RFLOAT(x)->value)); + return rb_float_new(exp(RFLOAT(x)->value)); } static VALUE @@ -69,7 +69,7 @@ math_log(obj, x) VALUE obj, x; { Need_Float(x); - return float_new(log(RFLOAT(x)->value)); + return rb_float_new(log(RFLOAT(x)->value)); } static VALUE @@ -77,7 +77,7 @@ math_log10(obj, x) VALUE obj, x; { Need_Float(x); - return float_new(log10(RFLOAT(x)->value)); + return rb_float_new(log10(RFLOAT(x)->value)); } static VALUE @@ -86,8 +86,8 @@ math_sqrt(obj, x) { Need_Float(x); - if (RFLOAT(x)->value < 0.0) ArgError("square root for negative number"); - return float_new(sqrt(RFLOAT(x)->value)); + if (RFLOAT(x)->value < 0.0) rb_raise(rb_eArgError, "square root for negative number"); + return rb_float_new(sqrt(RFLOAT(x)->value)); } static VALUE @@ -100,7 +100,7 @@ math_frexp(obj, x) Need_Float(x); d = frexp(RFLOAT(x)->value, &exp); - return assoc_new(float_new(d), INT2NUM(exp)); + return rb_assoc_new(rb_float_new(d), INT2NUM(exp)); } static VALUE @@ -110,36 +110,36 @@ math_ldexp(obj, x, n) double d; Need_Float(x); - return float_new(d = ldexp(RFLOAT(x)->value, NUM2INT(n))); + return rb_float_new(d = ldexp(RFLOAT(x)->value, NUM2INT(n))); } void Init_Math() { - mMath = rb_define_module("Math"); + rb_mMath = rb_define_module("Math"); #ifdef M_PI - rb_define_const(mMath, "PI", float_new(M_PI)); + rb_define_const(rb_mMath, "PI", rb_float_new(M_PI)); #else - rb_define_const(mMath, "PI", float_new(atan(1.0)*4.0)); + rb_define_const(rb_mMath, "PI", rb_float_new(atan(1.0)*4.0)); #endif #ifdef M_E - rb_define_const(mMath, "E", float_new(M_E)); + rb_define_const(rb_mMath, "E", rb_float_new(M_E)); #else - rb_define_const(mMath, "E", float_new(exp(1.0))); + rb_define_const(rb_mMath, "E", rb_float_new(exp(1.0))); #endif - rb_define_module_function(mMath, "atan2", math_atan2, 2); - rb_define_module_function(mMath, "cos", math_cos, 1); - rb_define_module_function(mMath, "sin", math_sin, 1); - rb_define_module_function(mMath, "tan", math_tan, 1); + rb_define_module_function(rb_mMath, "atan2", math_atan2, 2); + rb_define_module_function(rb_mMath, "cos", math_cos, 1); + rb_define_module_function(rb_mMath, "sin", math_sin, 1); + rb_define_module_function(rb_mMath, "tan", math_tan, 1); - rb_define_module_function(mMath, "exp", math_exp, 1); - rb_define_module_function(mMath, "log", math_log, 1); - rb_define_module_function(mMath, "log10", math_log10, 1); - rb_define_module_function(mMath, "sqrt", math_sqrt, 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); + rb_define_module_function(rb_mMath, "sqrt", math_sqrt, 1); - rb_define_module_function(mMath, "frexp", math_frexp, 1); - rb_define_module_function(mMath, "ldexp", math_ldexp, 2); + rb_define_module_function(rb_mMath, "frexp", math_frexp, 1); + rb_define_module_function(rb_mMath, "ldexp", math_ldexp, 2); } |