1/* Test mpf_integer_p. 2 3Copyright 2001, 2014 Free Software Foundation, Inc. 4 5This file is part of the GNU MP Library test suite. 6 7The GNU MP Library test suite is free software; you can redistribute it 8and/or modify it under the terms of the GNU General Public License as 9published by the Free Software Foundation; either version 3 of the License, 10or (at your option) any later version. 11 12The GNU MP Library test suite is distributed in the hope that it will be 13useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 15Public License for more details. 16 17You should have received a copy of the GNU General Public License along with 18the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ 19 20#include <stdio.h> 21#include <stdlib.h> 22#include "gmp-impl.h" 23#include "tests.h" 24 25 26void 27one (mpf_srcptr f, int want) 28{ 29 int got; 30 got = mpf_integer_p (f); 31 if (got != want) 32 { 33 printf ("mpf_integer_p got %d want %d\n", got, want); 34 mpf_trace (" f", f); 35 abort (); 36 } 37} 38 39void 40all (mpf_ptr f, int want) 41{ 42 one (f, want); 43 mpf_neg (f, f); 44 one (f, want); 45} 46 47int 48main (void) 49{ 50 mpf_t f; 51 52 tests_start (); 53 mpf_init2 (f, 200L); 54 55 mpf_set_ui (f, 0L); 56 one (f, 1); 57 58 mpf_set_ui (f, 1L); 59 all (f, 1); 60 61 mpf_set_ui (f, 1L); 62 mpf_div_2exp (f, f, 1L); 63 all (f, 0); 64 65 mpf_set_ui (f, 1L); 66 mpf_div_2exp (f, f, 5000L); 67 all (f, 0); 68 69 mpf_set_ui (f, 1L); 70 mpf_mul_2exp (f, f, 5000L); 71 all (f, 1); 72 73 mpf_set_str (f, "0.5", 10); 74 all (f, 0); 75 76 mpf_set_str (f, "2.5", 10); 77 all (f, 0); 78 79 mpf_set_ui (f, 1L); 80 mpf_div_ui (f, f, 3L); 81 all (f, 0); 82 83 mpf_set_ui (f, 7L); 84 mpf_div_ui (f, f, 3L); 85 all (f, 0); 86 87 mpf_clear (f); 88 tests_end (); 89 exit (0); 90} 91