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