1 /* Test mpf_set_ui and mpf_init_set_ui.
3 Copyright 2000, 2001, 2003 Free Software Foundation, Inc.
5 This file is part of the GNU MP Library.
7 The GNU MP Library is free software; you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
12 The GNU MP Library is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15 License for more details.
17 You should have received a copy of the GNU Lesser General Public License
18 along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
32 mp_limb_t want_data[2];
38 #if GMP_NUMB_BITS >= BITS_PER_ULONG
39 { ULONG_MAX, 1, { ULONG_MAX, 0 } },
40 { ULONG_HIGHBIT, 1, { ULONG_HIGHBIT, 0 } },
42 { ULONG_MAX, 2, { ULONG_MAX & GMP_NUMB_MASK,
43 ULONG_MAX >> GMP_NUMB_BITS } },
44 { LONG_HIGHBIT, 2, { 0,
45 ULONG_HIGHBIT >> GMP_NUMB_BITS } },
52 for (i = 0; i < numberof (data); i++)
55 mpf_set_ui (x, data[i].x);
57 if (x->_mp_size != data[i].want_size
58 || refmpn_cmp_allowzero (x->_mp_d, data[i].want_data,
59 ABS (data[i].want_size)) != 0
60 || x->_mp_exp != ABS (data[i].want_size))
62 printf ("mpf_set_ui wrong on data[%d]\n", i);
67 mpf_init_set_ui (x, data[i].x);
69 if (x->_mp_size != data[i].want_size
70 || refmpn_cmp_allowzero (x->_mp_d, data[i].want_data,
71 ABS (data[i].want_size)) != 0
72 || x->_mp_exp != ABS (data[i].want_size))
74 printf ("mpf_init_set_ui wrong on data[%d]\n", i);