Mercurial > hg > xemacs-beta
changeset 4883:f730384b8ddf
Be more careful about canonical integer forms when dealing with ratios.
2010-01-24 Aidan Kehoe <kehoea@parhasard.net>
* 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.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Sun, 24 Jan 2010 19:56:31 +0000 |
parents | e533a9912ef1 |
children | 29fb3baea939 77e3b19bd245 |
files | src/ChangeLog src/number.c |
diffstat | 2 files changed, 20 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- 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 <kehoea@parhasard.net> + + * 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 <acs@xemacs.org> * fileio.c (check_writable): Remove cast from 2010-01-14
--- 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)))