Annotation of OpenXM_contrib/gmp/mpq/equal.c, Revision 1.1.1.3
1.1 maekawa 1: /* mpq_equal(u,v) -- Compare U, V. Return non-zero if they are equal, zero
2: if they are non-equal.
3:
1.1.1.3 ! ohara 4: Copyright 1996, 2001, 2002 Free Software Foundation, Inc.
1.1 maekawa 5:
6: This file is part of the GNU MP Library.
7:
8: The GNU MP Library is free software; you can redistribute it and/or modify
1.1.1.2 maekawa 9: it under the terms of the GNU Lesser General Public License as published by
10: the Free Software Foundation; either version 2.1 of the License, or (at your
1.1 maekawa 11: option) any later version.
12:
13: The GNU MP Library is distributed in the hope that it will be useful, but
14: WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
1.1.1.2 maekawa 15: or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
1.1 maekawa 16: License for more details.
17:
1.1.1.2 maekawa 18: You should have received a copy of the GNU Lesser General Public License
1.1 maekawa 19: along with the GNU MP Library; see the file COPYING.LIB. If not, write to
20: the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
21: MA 02111-1307, USA. */
22:
23: #include "gmp.h"
24: #include "gmp-impl.h"
25:
26: int
27: mpq_equal (mpq_srcptr op1, mpq_srcptr op2)
28: {
1.1.1.3 ! ohara 29: mp_size_t num1_size, num2_size, den1_size, den2_size, i;
! 30: mp_srcptr num1_ptr, num2_ptr, den1_ptr, den2_ptr;
! 31:
! 32: /* need fully canonical for correct results */
! 33: ASSERT_MPQ_CANONICAL (op1);
! 34: ASSERT_MPQ_CANONICAL (op2);
! 35:
! 36: num1_size = op1->_mp_num._mp_size;
! 37: num2_size = op2->_mp_num._mp_size;
! 38: if (num1_size != num2_size)
! 39: return 0;
! 40:
! 41: num1_ptr = op1->_mp_num._mp_d;
! 42: num2_ptr = op2->_mp_num._mp_d;
! 43: num1_size = ABS (num1_size);
! 44: for (i = 0; i < num1_size; i++)
! 45: if (num1_ptr[i] != num2_ptr[i])
! 46: return 0;
! 47:
! 48: den1_size = op1->_mp_den._mp_size;
! 49: den2_size = op2->_mp_den._mp_size;
! 50: if (den1_size != den2_size)
! 51: return 0;
! 52:
! 53: den1_ptr = op1->_mp_den._mp_d;
! 54: den2_ptr = op2->_mp_den._mp_d;
! 55: for (i = 0; i < den1_size; i++)
! 56: if (den1_ptr[i] != den2_ptr[i])
! 57: return 0;
! 58:
! 59: return 1;
1.1 maekawa 60: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>