1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* complex.c (nucomp_s_polar): now arg is optional.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23961 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
tadf 2009-07-05 13:46:10 +00:00
parent 5a763bb525
commit b50cc1fe57
2 changed files with 20 additions and 4 deletions

View file

@ -1,3 +1,7 @@
Sun Jul 5 22:43:13 2009 Tadayoshi Funaba <tadf@dotrb.org>
* complex.c (nucomp_s_polar): now arg is optional.
Sun Jul 5 20:40:35 2009 Tadayoshi Funaba <tadf@dotrb.org>
* complex.c (float_arg): returns PI for -0.0.

View file

@ -548,13 +548,25 @@ f_complex_polar(VALUE klass, VALUE x, VALUE y)
/*
* call-seq:
* Complex.polar(abs, arg) -> complex
* Complex.polar(abs[, arg]) -> complex
*
* Returns a complex object which denotes the given polar form.
*/
static VALUE
nucomp_s_polar(VALUE klass, VALUE abs, VALUE arg)
nucomp_s_polar(int argc, VALUE *argv, VALUE klass)
{
VALUE abs, arg;
switch (rb_scan_args(argc, argv, "11", &abs, &arg)) {
case 1:
nucomp_real_check(abs);
arg = ZERO;
break;
default:
nucomp_real_check(abs);
nucomp_real_check(arg);
break;
}
return f_complex_polar(klass, abs, arg);
}
@ -1260,7 +1272,7 @@ rb_complex_new(VALUE x, VALUE y)
VALUE
rb_complex_polar(VALUE x, VALUE y)
{
return nucomp_s_polar(rb_cComplex, x, y);
return f_complex_polar(rb_cComplex, x, y);
}
static VALUE nucomp_s_convert(int argc, VALUE *argv, VALUE klass);
@ -1840,7 +1852,7 @@ Init_Complex(void)
rb_define_singleton_method(rb_cComplex, "rectangular", nucomp_s_new, -1);
rb_define_singleton_method(rb_cComplex, "rect", nucomp_s_new, -1);
rb_define_singleton_method(rb_cComplex, "polar", nucomp_s_polar, 2);
rb_define_singleton_method(rb_cComplex, "polar", nucomp_s_polar, -1);
rb_define_global_function("Complex", nucomp_f_complex, -1);