Introduce math_arc macro
This commit is contained in:
parent
5f411b9b3e
commit
38ef5f7b35
Notes:
git
2023-05-13 05:54:38 +00:00
18
math.c
18
math.c
@ -170,6 +170,12 @@ math_tan(VALUE unused_obj, VALUE x)
|
|||||||
return DBL2NUM(tan(Get_Double(x)));
|
return DBL2NUM(tan(Get_Double(x)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define math_arc(num, func) \
|
||||||
|
double d; \
|
||||||
|
d = Get_Double((num)); \
|
||||||
|
domain_check_range(d, -1.0, 1.0, #func); \
|
||||||
|
return DBL2NUM(func(d));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* Math.acos(x) -> float
|
* Math.acos(x) -> float
|
||||||
@ -190,11 +196,7 @@ math_tan(VALUE unused_obj, VALUE x)
|
|||||||
static VALUE
|
static VALUE
|
||||||
math_acos(VALUE unused_obj, VALUE x)
|
math_acos(VALUE unused_obj, VALUE x)
|
||||||
{
|
{
|
||||||
double d;
|
math_arc(x, acos)
|
||||||
|
|
||||||
d = Get_Double(x);
|
|
||||||
domain_check_range(d, -1.0, 1.0, "acos");
|
|
||||||
return DBL2NUM(acos(d));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -217,11 +219,7 @@ math_acos(VALUE unused_obj, VALUE x)
|
|||||||
static VALUE
|
static VALUE
|
||||||
math_asin(VALUE unused_obj, VALUE x)
|
math_asin(VALUE unused_obj, VALUE x)
|
||||||
{
|
{
|
||||||
double d;
|
math_arc(x, asin)
|
||||||
|
|
||||||
d = Get_Double(x);
|
|
||||||
domain_check_range(d, -1.0, 1.0, "asin");
|
|
||||||
return DBL2NUM(asin(d));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user