mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
rb_rational_raw: make a denominator always positive
This commit is contained in:
parent
73618d84e8
commit
47465ab1cc
3 changed files with 26 additions and 0 deletions
|
@ -1927,6 +1927,10 @@ rb_gcdlcm(VALUE self, VALUE other)
|
|||
VALUE
|
||||
rb_rational_raw(VALUE x, VALUE y)
|
||||
{
|
||||
if (INT_NEGATIVE_P(y)) {
|
||||
x = rb_int_uminus(x);
|
||||
y = rb_int_uminus(y);
|
||||
}
|
||||
return nurat_s_new_internal(rb_cRational, x, y);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue