mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
complex.c: small optimization of Complex#**
* complex.c (rb_complex_pow): calculate power of a Fixnum without allocating intermediate Complex objects, and avoid unexpected NaNs. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65190 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c561284bc2
commit
b4bbfe4bb9
5 changed files with 79 additions and 44 deletions
|
@ -1001,8 +1001,8 @@ f_odd_p(VALUE integer)
|
|||
* Rational(1, 2) ** 0 #=> (1/1)
|
||||
* Rational(1, 2) ** 0.0 #=> 1.0
|
||||
*/
|
||||
static VALUE
|
||||
nurat_expt(VALUE self, VALUE other)
|
||||
VALUE
|
||||
rb_rational_pow(VALUE self, VALUE other)
|
||||
{
|
||||
if (k_numeric_p(other) && k_exact_zero_p(other))
|
||||
return f_rational_new_bang1(CLASS_OF(self), ONE);
|
||||
|
@ -1077,6 +1077,7 @@ nurat_expt(VALUE self, VALUE other)
|
|||
return rb_num_coerce_bin(self, other, rb_intern("**"));
|
||||
}
|
||||
}
|
||||
#define nurat_expt rb_rational_pow
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue