diff options
author | S-H-GAMELINKS <[email protected]> | 2023-05-12 12:03:19 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2023-05-13 14:54:18 +0900 |
commit | 38ef5f7b35cab5064c4ed48c24bbd7a5eeb6e918 (patch) | |
tree | be7c627ae9984f3ce231220babbc58723eb0e164 /math.c | |
parent | 5f411b9b3e45a40df788f85156d4337206686deb (diff) |
Introduce math_arc macro
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/7799
Diffstat (limited to 'math.c')
-rw-r--r-- | math.c | 18 |
1 files changed, 8 insertions, 10 deletions
@@ -170,6 +170,12 @@ math_tan(VALUE unused_obj, VALUE 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: * Math.acos(x) -> float @@ -190,11 +196,7 @@ math_tan(VALUE unused_obj, VALUE x) static VALUE math_acos(VALUE unused_obj, VALUE x) { - double d; - - d = Get_Double(x); - domain_check_range(d, -1.0, 1.0, "acos"); - return DBL2NUM(acos(d)); + math_arc(x, acos) } /* @@ -217,11 +219,7 @@ math_acos(VALUE unused_obj, VALUE x) static VALUE math_asin(VALUE unused_obj, VALUE x) { - double d; - - d = Get_Double(x); - domain_check_range(d, -1.0, 1.0, "asin"); - return DBL2NUM(asin(d)); + math_arc(x, asin) } /* |