151c586b8Smrg /* mpf_integer_p -- test whether an mpf is an integer */ 251c586b8Smrg 351c586b8Smrg /* 4*ce543368Smrg Copyright 2001, 2002, 2014-2015 Free Software Foundation, Inc. 551c586b8Smrg 651c586b8Smrg This file is part of the GNU MP Library. 751c586b8Smrg 851c586b8Smrg The GNU MP Library is free software; you can redistribute it and/or modify 9*ce543368Smrg it under the terms of either: 10*ce543368Smrg 11*ce543368Smrg * the GNU Lesser General Public License as published by the Free 12*ce543368Smrg Software Foundation; either version 3 of the License, or (at your 1351c586b8Smrg option) any later version. 1451c586b8Smrg 15*ce543368Smrg or 16*ce543368Smrg 17*ce543368Smrg * the GNU General Public License as published by the Free Software 18*ce543368Smrg Foundation; either version 2 of the License, or (at your option) any 19*ce543368Smrg later version. 20*ce543368Smrg 21*ce543368Smrg or both in parallel, as here. 22*ce543368Smrg 2351c586b8Smrg The GNU MP Library is distributed in the hope that it will be useful, but 2451c586b8Smrg WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 25*ce543368Smrg or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 26*ce543368Smrg for more details. 2751c586b8Smrg 28*ce543368Smrg You should have received copies of the GNU General Public License and the 29*ce543368Smrg GNU Lesser General Public License along with the GNU MP Library. If not, 30*ce543368Smrg see https://www.gnu.org/licenses/. */ 3151c586b8Smrg 3251c586b8Smrg #include "gmp-impl.h" 3351c586b8Smrg 3451c586b8Smrg 3551c586b8Smrg int mpf_integer_p(mpf_srcptr f)36dab47db4Smrgmpf_integer_p (mpf_srcptr f) __GMP_NOTHROW 3751c586b8Smrg { 38*ce543368Smrg mp_srcptr fp; 3951c586b8Smrg mp_exp_t exp; 40*ce543368Smrg mp_size_t size; 4151c586b8Smrg 4251c586b8Smrg size = SIZ (f); 4351c586b8Smrg exp = EXP (f); 4451c586b8Smrg if (exp <= 0) 45*ce543368Smrg return (size == 0); /* zero is an integer, 46*ce543368Smrg others have only fraction limbs */ 47*ce543368Smrg size = ABS (size); 4851c586b8Smrg 49*ce543368Smrg /* Ignore zeroes at the low end of F. */ 50*ce543368Smrg for (fp = PTR (f); *fp == 0; ++fp) 51*ce543368Smrg --size; 5251c586b8Smrg 53*ce543368Smrg /* no fraction limbs */ 54*ce543368Smrg return size <= exp; 5551c586b8Smrg } 56