1/* comparison predicates 2 3Copyright 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc. 4Contributed by the AriC and Caramel projects, INRIA. 5 6This file is part of the GNU MPFR Library. 7 8The GNU MPFR Library is free software; you can redistribute it and/or modify 9it under the terms of the GNU Lesser General Public License as published by 10the Free Software Foundation; either version 3 of the License, or (at your 11option) any later version. 12 13The GNU MPFR Library is distributed in the hope that it will be useful, but 14WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 16License for more details. 17 18You should have received a copy of the GNU Lesser General Public License 19along with the GNU MPFR Library; see the file COPYING.LESSER. If not, see 20http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., 2151 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ 22 23#include "mpfr-impl.h" 24 25/* Note: these functions currently use mpfr_cmp; they could have their 26 own code to be faster. */ 27 28/* = < > unordered 29 * mpfr_greater_p 0 0 1 0 30 * mpfr_greaterequal_p 1 0 1 0 31 * mpfr_less_p 0 1 0 0 32 * mpfr_lessequal_p 1 1 0 0 33 * mpfr_lessgreater_p 0 1 1 0 34 * mpfr_equal_p 1 0 0 0 35 * mpfr_unordered_p 0 0 0 1 36 */ 37 38int 39mpfr_greater_p (mpfr_srcptr x, mpfr_srcptr y) 40{ 41 return MPFR_IS_NAN(x) || MPFR_IS_NAN(y) ? 0 : (mpfr_cmp (x, y) > 0); 42} 43 44int 45mpfr_greaterequal_p (mpfr_srcptr x, mpfr_srcptr y) 46{ 47 return MPFR_IS_NAN(x) || MPFR_IS_NAN(y) ? 0 : (mpfr_cmp (x, y) >= 0); 48} 49 50int 51mpfr_less_p (mpfr_srcptr x, mpfr_srcptr y) 52{ 53 return MPFR_IS_NAN(x) || MPFR_IS_NAN(y) ? 0 : (mpfr_cmp (x, y) < 0); 54} 55 56int 57mpfr_lessequal_p (mpfr_srcptr x, mpfr_srcptr y) 58{ 59 return MPFR_IS_NAN(x) || MPFR_IS_NAN(y) ? 0 : (mpfr_cmp (x, y) <= 0); 60} 61 62int 63mpfr_lessgreater_p (mpfr_srcptr x, mpfr_srcptr y) 64{ 65 return MPFR_IS_NAN(x) || MPFR_IS_NAN(y) ? 0 : (mpfr_cmp (x, y) != 0); 66} 67 68int 69mpfr_equal_p (mpfr_srcptr x, mpfr_srcptr y) 70{ 71 return MPFR_IS_NAN(x) || MPFR_IS_NAN(y) ? 0 : (mpfr_cmp (x, y) == 0); 72} 73 74int 75mpfr_unordered_p (mpfr_srcptr x, mpfr_srcptr y) 76{ 77 return MPFR_IS_NAN(x) || MPFR_IS_NAN(y); 78} 79