mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Do not round a**b
to infinity
... instead, just calculate the value unless it is too big. Also, this change raises an ArgumentError if it is expected to exceed 16 GB in a 64-bit environment. (It is possible to calculate it straightforward, but it would likely be out-of-memory, so I didn't think it would make sense.) [Feature #20811]
This commit is contained in:
parent
f7b334e002
commit
45cd4a8296
Notes:
git
2024-11-08 10:49:14 +00:00
7 changed files with 122 additions and 61 deletions
|
@ -1048,8 +1048,7 @@ rb_rational_pow(VALUE self, VALUE other)
|
|||
}
|
||||
}
|
||||
else if (RB_BIGNUM_TYPE_P(other)) {
|
||||
rb_warn("in a**b, b may be too big");
|
||||
return rb_float_pow(nurat_to_f(self), other);
|
||||
rb_raise(rb_eArgError, "exponent is too large");
|
||||
}
|
||||
else if (RB_FLOAT_TYPE_P(other) || RB_TYPE_P(other, T_RATIONAL)) {
|
||||
return rb_float_pow(nurat_to_f(self), other);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue