rb_rational_raw: convert num and den by to_int

This commit is contained in:
Kenta Murata 2020-01-17 10:47:20 +09:00
parent 47465ab1cc
commit 5275d8bf4c
No known key found for this signature in database
GPG key ID: CEFE8AFB6081B062
2 changed files with 28 additions and 0 deletions

View file

@ -1927,6 +1927,10 @@ rb_gcdlcm(VALUE self, VALUE other)
VALUE
rb_rational_raw(VALUE x, VALUE y)
{
if (! RB_INTEGER_TYPE_P(x))
x = rb_to_int(x);
if (! RB_INTEGER_TYPE_P(y))
y = rb_to_int(y);
if (INT_NEGATIVE_P(y)) {
x = rb_int_uminus(x);
y = rb_int_uminus(y);