ごとけんです

うまく機能していなかった Precision を使えるように直しました.

-- gotoken

diff -u0 numeric.c-990205 numeric.c --- numeric.c-990205 Fri Feb 5 19:27:31 1999 +++ numeric.c Mon Feb 8 20:42:36 1999 @@ -797 +797,10 @@ - return rb_funcall(x, rb_intern("to_i"), 0); + switch (TYPE(x)) { + case T_FIXNUM: + case T_BIGNUM: + return x; + case T_FLOAT: + return rb_funcall(x, rb_intern("to_i"), 0); + default: + rb_raise(rb_eTypeError, "failed to convert %s into Integer", + rb_class2name(CLASS_OF(x))); + } @@ -804 +813,10 @@ - return rb_funcall(x, rb_intern("to_f"), 0); + switch (TYPE(x)) { + case T_FIXNUM: + case T_BIGNUM: + return rb_funcall(x, rb_intern("to_f"), 0); + case T_FLOAT: + return x; + default: + rb_raise(rb_eTypeError, "failed to convert %s into Float", + rb_class2name(CLASS_OF(x))); + } diff -u0 prec.c-990205 prec.c --- prec.c-990205 Tue Jan 26 13:53:36 1999 +++ prec.c Mon Feb 8 19:53:28 1999 @@ -17 +17 @@ -static ID prc_if; +static ID prc_pr, prc_if; @@ -32 +32 @@ - return rb_funcall(klass, prc_if, 1, x); + return rb_funcall(x, prc_pr, 1, klass); @@ -41 +41,19 @@ - return rb_funcall(klass, prc_if, 1, x); + return rb_funcall(x, prc_pr, 1, klass); +} + +VALUE +prec_coerce(x, y) +{ + if (TYPE(x) == TYPE(y)) + return rb_assoc_new(y, x); + else { + return rb_assoc_new(rb_funcall(y, prc_pr, 1, CLASS_OF(x)), x); + } +} + +static VALUE +prec_induced_from(module, x) + +{ + rb_raise(rb_eTypeError, "undefined conversion from %s into %s", + rb_class2name(CLASS_OF(x)), rb_class2name(module)); @@ -43,0 +62,18 @@ +static VALUE +prec_append_features(module, include) + VALUE module, include; +{ + switch (TYPE(include)) { + case T_CLASS: + case T_MODULE: + break; + default: + Check_Type(include, T_CLASS); + break; + } + rb_include_module(include, module); + rb_define_singleton_method(include, "induced_from", prec_induced_from, 1); + return module; +} + + @@ -47,0 +84 @@ + rb_define_singleton_method(rb_mPrecision, "append_features", prec_append_features, 1); @@ -50,0 +88 @@ + rb_define_method(rb_mPrecision, "coerce", prec_coerce, 1); @@ -51,0 +90 @@ + prc_pr = rb_intern("prec");