diff options
author | tadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-09-19 13:55:52 +0000 |
---|---|---|
committer | tadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-09-19 13:55:52 +0000 |
commit | f2cb79ffee99c3561503ed7a1c107ca3ec6a48a7 (patch) | |
tree | 58ea38242497b45ea49f497d8693123fe508e944 /complex.c | |
parent | 396650e0bd353e30b873683f008f92e2aa498971 (diff) | |
download | ruby-f2cb79ffee99c3561503ed7a1c107ca3ec6a48a7.tar.gz |
* complex.c: uses f_(in)?exact_p macro.
* rational.c: ditto.
* bignum.c (rb_big_pow): bignum**bignum - should calculate without
rational.
* lib/complex.rb: should override Math module at most once.
* lib/mathn.rb: requires 'cmath' directly.
-この行以下は無視されます --
M complex.c
M ChangeLog
M lib/mathn.rb
M lib/complex.rb
M bignum.c
M rational.c
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'complex.c')
-rw-r--r-- | complex.c | 18 |
1 files changed, 10 insertions, 8 deletions
@@ -247,6 +247,9 @@ k_complex_p(VALUE x) return f_kind_of_p(x, rb_cComplex); } +#define k_exact_p(x) (!k_float_p(x)) +#define k_inexact_p(x) k_float_p(x) + #define get_dat1(x) \ struct RComplex *dat;\ dat = ((struct RComplex *)(x)) @@ -334,7 +337,7 @@ nucomp_s_canonicalize_internal(VALUE klass, VALUE real, VALUE image) #define CL_CANON #ifdef CL_CANON if (f_zero_p(image) && f_unify_p(klass) && - !k_float_p(real) && !k_float_p(image)) + k_exact_p(real) && k_exact_p(image)) return real; #else if (f_zero_p(image) && f_unify_p(klass)) @@ -986,7 +989,7 @@ nucomp_to_i(VALUE self) { get_dat1(self); - if (k_float_p(dat->image) || !f_zero_p(dat->image)) { + if (k_inexact_p(dat->image) || !f_zero_p(dat->image)) { VALUE s = f_to_s(self); rb_raise(rb_eRangeError, "can't convert %s into Integer", StringValuePtr(s)); @@ -999,7 +1002,7 @@ nucomp_to_f(VALUE self) { get_dat1(self); - if (k_float_p(dat->image) || !f_zero_p(dat->image)) { + if (k_inexact_p(dat->image) || !f_zero_p(dat->image)) { VALUE s = f_to_s(self); rb_raise(rb_eRangeError, "can't convert %s into Float", StringValuePtr(s)); @@ -1012,7 +1015,7 @@ nucomp_to_r(VALUE self) { get_dat1(self); - if (k_float_p(dat->image) || !f_zero_p(dat->image)) { + if (k_inexact_p(dat->image) || !f_zero_p(dat->image)) { VALUE s = f_to_s(self); rb_raise(rb_eRangeError, "can't convert %s into Rational", StringValuePtr(s)); @@ -1183,7 +1186,6 @@ string_to_c_internal(VALUE self) return rb_assoc_new(rb_complex_polar(r, i), re); else return rb_assoc_new(rb_complex_new2(r, i), re); - } } @@ -1257,7 +1259,7 @@ nucomp_s_convert(int argc, VALUE *argv, VALUE klass) { get_dat1(a1); - if (!k_float_p(dat->image) && f_zero_p(dat->image)) + if (k_exact_p(dat->image) && f_zero_p(dat->image)) a1 = dat->real; } } @@ -1267,7 +1269,7 @@ nucomp_s_convert(int argc, VALUE *argv, VALUE klass) { get_dat1(a2); - if (!k_float_p(dat->image) && f_zero_p(dat->image)) + if (k_exact_p(dat->image) && f_zero_p(dat->image)) a2 = dat->real; } } @@ -1338,7 +1340,7 @@ numeric_arg(VALUE self) static VALUE numeric_rect(VALUE self) { - return rb_assoc_new(self, ZERO); + return rb_assoc_new(self, INT2FIX(0)); } static VALUE |