# HG changeset patch # User Aidan Kehoe # Date 1264362991 0 # Node ID f730384b8ddff2707385f631524f749ec7d1470c # Parent e533a9912ef137f398c4e45420857cebc4d68318 Be more careful about canonical integer forms when dealing with ratios. 2010-01-24 Aidan Kehoe * number.c (Fnumerator, Fdenominator, Fcanonicalize_number): Be more careful to return integers in their canonical forms here, and to give the same answer all the time when treating a rational that is itself is an integer as a ratio. diff -r e533a9912ef1 -r f730384b8ddf src/ChangeLog --- a/src/ChangeLog Wed Jan 20 17:30:29 2010 +0000 +++ b/src/ChangeLog Sun Jan 24 19:56:31 2010 +0000 @@ -1,3 +1,10 @@ +2010-01-24 Aidan Kehoe + + * number.c (Fnumerator, Fdenominator, Fcanonicalize_number): + Be more careful to return integers in their canonical forms here, + and to give the same answer all the time when treating a rational + that is itself is an integer as a ratio. + 2010-01-17 Vin Shelton * fileio.c (check_writable): Remove cast from 2010-01-14 diff -r e533a9912ef1 -r f730384b8ddf src/number.c --- a/src/number.c Wed Jan 20 17:30:29 2010 +0000 +++ b/src/number.c Sun Jan 24 19:56:31 2010 +0000 @@ -248,12 +248,13 @@ { CONCHECK_RATIONAL (rational); #ifdef HAVE_RATIO - return RATIOP (rational) - ? make_bignum_bg (XRATIO_NUMERATOR (rational)) - : rational; -#else + if (RATIOP (rational)) + { + return + Fcanonicalize_number (make_bignum_bg (XRATIO_NUMERATOR (rational))); + } +#endif return rational; -#endif } DEFUN ("denominator", Fdenominator, 1, 1, 0, /* @@ -264,12 +265,13 @@ { CONCHECK_RATIONAL (rational); #ifdef HAVE_RATIO - return RATIOP (rational) - ? make_bignum_bg (XRATIO_DENOMINATOR (rational)) - : make_int (1); -#else - return rational; + if (RATIOP (rational)) + { + return Fcanonicalize_number (make_bignum_bg + (XRATIO_DENOMINATOR (rational))); + } #endif + return make_int (1); } @@ -451,7 +453,7 @@ if (RATIOP (number) && bignum_fits_long_p (XRATIO_DENOMINATOR (number)) && bignum_to_long (XRATIO_DENOMINATOR (number)) == 1L) - number = make_bignum_bg (XRATIO_NUMERATOR (number)); + number = Fcanonicalize_number (make_bignum_bg (XRATIO_NUMERATOR (number))); #endif #ifdef HAVE_BIGNUM if (BIGNUMP (number) && bignum_fits_emacs_int_p (XBIGNUM_DATA (number)))