summaryrefslogtreecommitdiff
path: root/math.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-01-16 12:19:22 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-01-16 12:19:22 +0000
commitfd1d8cdc09ed86e4a0812120a17ff0d7b04adcaf (patch)
tree341289a84a427f1e92425c7ebf82d2f1733e9a40 /math.c
parentf12baed5df6d3c213dd75d2f0d9f36bb179fb843 (diff)
*** empty log message ***
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/RUBY@11 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'math.c')
-rw-r--r--math.c52
1 files changed, 18 insertions, 34 deletions
diff --git a/math.c b/math.c
index 7b75a01..0e42703 100644
--- a/math.c
+++ b/math.c
@@ -14,16 +14,8 @@
#include <math.h>
VALUE mMath;
-VALUE float_new();
-VALUE f_float();
-
-#define Need_Float(x) \
-if (FIXNUM_P(x)) {\
- (x) = (struct RFloat*)float_new((double)FIX2INT(x));\
-} else {\
- (x) = (struct RFloat*)f_float(x, x);\
-}
+#define Need_Float(x) (x) = rb_Float(x)
#define Need_Float2(x,y) {\
Need_Float(x);\
Need_Float(y);\
@@ -31,79 +23,71 @@ if (FIXNUM_P(x)) {\
static VALUE
math_atan2(obj, x, y)
- VALUE obj;
- struct RFloat *x, *y;
+ VALUE obj, x, y;
{
Need_Float2(x, y);
- return float_new(atan2(x->value, y->value));
+ return float_new(atan2(RFLOAT(x)->value, RFLOAT(y)->value));
}
static VALUE
math_cos(obj, x)
- VALUE obj;
- struct RFloat *x;
+ VALUE obj, x;
{
Need_Float(x);
- return float_new(cos(x->value));
+ return float_new(cos(RFLOAT(x)->value));
}
static VALUE
math_sin(obj, x)
- VALUE obj;
- struct RFloat *x;
+ VALUE obj, x;
{
Need_Float(x);
- return float_new(sin(x->value));
+ return float_new(sin(RFLOAT(x)->value));
}
static VALUE
math_tan(obj, x)
- VALUE obj;
- struct RFloat *x;
+ VALUE obj, x;
{
Need_Float(x);
- return float_new(tan(x->value));
+ return float_new(tan(RFLOAT(x)->value));
}
static VALUE
math_exp(obj, x)
- VALUE obj;
- struct RFloat *x;
+ VALUE obj, x;
{
Need_Float(x);
- return float_new(exp(x->value));
+ return float_new(exp(RFLOAT(x)->value));
}
static VALUE
math_log(obj, x)
- VALUE obj;
- struct RFloat *x;
+ VALUE obj, x;
{
Need_Float(x);
- return float_new(log(x->value));
+ return float_new(log(RFLOAT(x)->value));
}
static VALUE
math_log10(obj, x)
- VALUE obj;
- struct RFloat *x;
+ VALUE obj, x;
{
Need_Float(x);
- return float_new(log10(x->value));
+ return float_new(log10(RFLOAT(x)->value));
}
static VALUE
math_sqrt(obj, x)
- VALUE obj;
- struct RFloat *x;
+ VALUE obj, x;
{
Need_Float(x);
- if (x->value < 0.0) ArgError("square root for negative number");
- return float_new(sqrt(x->value));
+ if (RFLOAT(x)->value < 0.0) ArgError("square root for negative number");
+ return float_new(sqrt(RFLOAT(x)->value));
}
void