diff options
Diffstat (limited to 'tests')
66 files changed, 1532 insertions, 1697 deletions
diff --git a/tests/Makefile.in b/tests/Makefile.in deleted file mode 100644 index 4cdbe3005..000000000 --- a/tests/Makefile.in +++ /dev/null @@ -1,920 +0,0 @@ -# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am - -# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - - -SHELL = @SHELL@ - -srcdir = @srcdir@ -top_srcdir = @top_srcdir@ -VPATH = @srcdir@ -prefix = @prefix@ -exec_prefix = @exec_prefix@ - -bindir = @bindir@ -sbindir = @sbindir@ -libexecdir = @libexecdir@ -datadir = @datadir@ -sysconfdir = @sysconfdir@ -sharedstatedir = @sharedstatedir@ -localstatedir = @localstatedir@ -libdir = @libdir@ -infodir = @infodir@ -mandir = @mandir@ -includedir = @includedir@ -oldincludedir = /usr/include - -DESTDIR = - -pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ - -top_builddir = .. - -ACLOCAL = @ACLOCAL@ -AUTOCONF = @AUTOCONF@ -AUTOMAKE = @AUTOMAKE@ -AUTOHEADER = @AUTOHEADER@ - -INSTALL = @INSTALL@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -transform = @program_transform_name@ - -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -CC = @CC@ -CFLAGS = @CFLAGS@ -LDFLAGS = @LDFLAGS@ -MAKEINFO = @MAKEINFO@ -MISCFLAGS = @MISCFLAGS@ -PACKAGE = @PACKAGE@ -RANLIB = @RANLIB@ -VERSION = @VERSION@ - -check_PROGRAMS = reuse tabs tadd tagm tcan_round tcmp tcmp2 tcmp_ui tdiv tdiv_ui tdump teq texp tget_str tlog tconst_log2 tmul tmul_2exp tmul_ui tout_str tconst_pi tpow trandom tround_prec tset_d tset_f tset_q tset_si tset_str tset_z tsqrt tsqrt_ui tui_div tui_sub tswap ttrunc trint tisnan tget_d tatan tcosh tsinh ttanh tacosh tasinh tatanh thyperbolic texp2 tfactorial tsub tasin tconst_euler tcos tsin ttan tsub_ui tset tlog1p texpm1 tlog2 tlog10 tui_pow tpow3 tadd_ui texceptions tfma thypot tacos -EXTRA_DIST = tgeneric.c - -LDADD = $(top_builddir)/libmpfr.a @LDADD@ -INCLUDES = -I$(top_srcdir) @INCLUDES@ -mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs -CONFIG_CLEAN_FILES = - -DEFS = @DEFS@ -I. -I$(srcdir) -CPPFLAGS = @CPPFLAGS@ -LIBS = @LIBS@ -reuse_SOURCES = reuse.c -reuse_OBJECTS = reuse.o -reuse_LDADD = $(LDADD) -reuse_DEPENDENCIES = $(top_builddir)/libmpfr.a -reuse_LDFLAGS = -tabs_SOURCES = tabs.c -tabs_OBJECTS = tabs.o -tabs_LDADD = $(LDADD) -tabs_DEPENDENCIES = $(top_builddir)/libmpfr.a -tabs_LDFLAGS = -tadd_SOURCES = tadd.c -tadd_OBJECTS = tadd.o -tadd_LDADD = $(LDADD) -tadd_DEPENDENCIES = $(top_builddir)/libmpfr.a -tadd_LDFLAGS = -tagm_SOURCES = tagm.c -tagm_OBJECTS = tagm.o -tagm_LDADD = $(LDADD) -tagm_DEPENDENCIES = $(top_builddir)/libmpfr.a -tagm_LDFLAGS = -tcan_round_SOURCES = tcan_round.c -tcan_round_OBJECTS = tcan_round.o -tcan_round_LDADD = $(LDADD) -tcan_round_DEPENDENCIES = $(top_builddir)/libmpfr.a -tcan_round_LDFLAGS = -tcmp_SOURCES = tcmp.c -tcmp_OBJECTS = tcmp.o -tcmp_LDADD = $(LDADD) -tcmp_DEPENDENCIES = $(top_builddir)/libmpfr.a -tcmp_LDFLAGS = -tcmp2_SOURCES = tcmp2.c -tcmp2_OBJECTS = tcmp2.o -tcmp2_LDADD = $(LDADD) -tcmp2_DEPENDENCIES = $(top_builddir)/libmpfr.a -tcmp2_LDFLAGS = -tcmp_ui_SOURCES = tcmp_ui.c -tcmp_ui_OBJECTS = tcmp_ui.o -tcmp_ui_LDADD = $(LDADD) -tcmp_ui_DEPENDENCIES = $(top_builddir)/libmpfr.a -tcmp_ui_LDFLAGS = -tdiv_SOURCES = tdiv.c -tdiv_OBJECTS = tdiv.o -tdiv_LDADD = $(LDADD) -tdiv_DEPENDENCIES = $(top_builddir)/libmpfr.a -tdiv_LDFLAGS = -tdiv_ui_SOURCES = tdiv_ui.c -tdiv_ui_OBJECTS = tdiv_ui.o -tdiv_ui_LDADD = $(LDADD) -tdiv_ui_DEPENDENCIES = $(top_builddir)/libmpfr.a -tdiv_ui_LDFLAGS = -tdump_SOURCES = tdump.c -tdump_OBJECTS = tdump.o -tdump_LDADD = $(LDADD) -tdump_DEPENDENCIES = $(top_builddir)/libmpfr.a -tdump_LDFLAGS = -teq_SOURCES = teq.c -teq_OBJECTS = teq.o -teq_LDADD = $(LDADD) -teq_DEPENDENCIES = $(top_builddir)/libmpfr.a -teq_LDFLAGS = -texp_SOURCES = texp.c -texp_OBJECTS = texp.o -texp_LDADD = $(LDADD) -texp_DEPENDENCIES = $(top_builddir)/libmpfr.a -texp_LDFLAGS = -tget_str_SOURCES = tget_str.c -tget_str_OBJECTS = tget_str.o -tget_str_LDADD = $(LDADD) -tget_str_DEPENDENCIES = $(top_builddir)/libmpfr.a -tget_str_LDFLAGS = -tlog_SOURCES = tlog.c -tlog_OBJECTS = tlog.o -tlog_LDADD = $(LDADD) -tlog_DEPENDENCIES = $(top_builddir)/libmpfr.a -tlog_LDFLAGS = -tconst_log2_SOURCES = tconst_log2.c -tconst_log2_OBJECTS = tconst_log2.o -tconst_log2_LDADD = $(LDADD) -tconst_log2_DEPENDENCIES = $(top_builddir)/libmpfr.a -tconst_log2_LDFLAGS = -tmul_SOURCES = tmul.c -tmul_OBJECTS = tmul.o -tmul_LDADD = $(LDADD) -tmul_DEPENDENCIES = $(top_builddir)/libmpfr.a -tmul_LDFLAGS = -tmul_2exp_SOURCES = tmul_2exp.c -tmul_2exp_OBJECTS = tmul_2exp.o -tmul_2exp_LDADD = $(LDADD) -tmul_2exp_DEPENDENCIES = $(top_builddir)/libmpfr.a -tmul_2exp_LDFLAGS = -tmul_ui_SOURCES = tmul_ui.c -tmul_ui_OBJECTS = tmul_ui.o -tmul_ui_LDADD = $(LDADD) -tmul_ui_DEPENDENCIES = $(top_builddir)/libmpfr.a -tmul_ui_LDFLAGS = -tout_str_SOURCES = tout_str.c -tout_str_OBJECTS = tout_str.o -tout_str_LDADD = $(LDADD) -tout_str_DEPENDENCIES = $(top_builddir)/libmpfr.a -tout_str_LDFLAGS = -tconst_pi_SOURCES = tconst_pi.c -tconst_pi_OBJECTS = tconst_pi.o -tconst_pi_LDADD = $(LDADD) -tconst_pi_DEPENDENCIES = $(top_builddir)/libmpfr.a -tconst_pi_LDFLAGS = -tpow_SOURCES = tpow.c -tpow_OBJECTS = tpow.o -tpow_LDADD = $(LDADD) -tpow_DEPENDENCIES = $(top_builddir)/libmpfr.a -tpow_LDFLAGS = -trandom_SOURCES = trandom.c -trandom_OBJECTS = trandom.o -trandom_LDADD = $(LDADD) -trandom_DEPENDENCIES = $(top_builddir)/libmpfr.a -trandom_LDFLAGS = -tround_prec_SOURCES = tround_prec.c -tround_prec_OBJECTS = tround_prec.o -tround_prec_LDADD = $(LDADD) -tround_prec_DEPENDENCIES = $(top_builddir)/libmpfr.a -tround_prec_LDFLAGS = -tset_d_SOURCES = tset_d.c -tset_d_OBJECTS = tset_d.o -tset_d_LDADD = $(LDADD) -tset_d_DEPENDENCIES = $(top_builddir)/libmpfr.a -tset_d_LDFLAGS = -tset_f_SOURCES = tset_f.c -tset_f_OBJECTS = tset_f.o -tset_f_LDADD = $(LDADD) -tset_f_DEPENDENCIES = $(top_builddir)/libmpfr.a -tset_f_LDFLAGS = -tset_q_SOURCES = tset_q.c -tset_q_OBJECTS = tset_q.o -tset_q_LDADD = $(LDADD) -tset_q_DEPENDENCIES = $(top_builddir)/libmpfr.a -tset_q_LDFLAGS = -tset_si_SOURCES = tset_si.c -tset_si_OBJECTS = tset_si.o -tset_si_LDADD = $(LDADD) -tset_si_DEPENDENCIES = $(top_builddir)/libmpfr.a -tset_si_LDFLAGS = -tset_str_SOURCES = tset_str.c -tset_str_OBJECTS = tset_str.o -tset_str_LDADD = $(LDADD) -tset_str_DEPENDENCIES = $(top_builddir)/libmpfr.a -tset_str_LDFLAGS = -tset_z_SOURCES = tset_z.c -tset_z_OBJECTS = tset_z.o -tset_z_LDADD = $(LDADD) -tset_z_DEPENDENCIES = $(top_builddir)/libmpfr.a -tset_z_LDFLAGS = -tsqrt_SOURCES = tsqrt.c -tsqrt_OBJECTS = tsqrt.o -tsqrt_LDADD = $(LDADD) -tsqrt_DEPENDENCIES = $(top_builddir)/libmpfr.a -tsqrt_LDFLAGS = -tsqrt_ui_SOURCES = tsqrt_ui.c -tsqrt_ui_OBJECTS = tsqrt_ui.o -tsqrt_ui_LDADD = $(LDADD) -tsqrt_ui_DEPENDENCIES = $(top_builddir)/libmpfr.a -tsqrt_ui_LDFLAGS = -tui_div_SOURCES = tui_div.c -tui_div_OBJECTS = tui_div.o -tui_div_LDADD = $(LDADD) -tui_div_DEPENDENCIES = $(top_builddir)/libmpfr.a -tui_div_LDFLAGS = -tui_sub_SOURCES = tui_sub.c -tui_sub_OBJECTS = tui_sub.o -tui_sub_LDADD = $(LDADD) -tui_sub_DEPENDENCIES = $(top_builddir)/libmpfr.a -tui_sub_LDFLAGS = -tswap_SOURCES = tswap.c -tswap_OBJECTS = tswap.o -tswap_LDADD = $(LDADD) -tswap_DEPENDENCIES = $(top_builddir)/libmpfr.a -tswap_LDFLAGS = -ttrunc_SOURCES = ttrunc.c -ttrunc_OBJECTS = ttrunc.o -ttrunc_LDADD = $(LDADD) -ttrunc_DEPENDENCIES = $(top_builddir)/libmpfr.a -ttrunc_LDFLAGS = -trint_SOURCES = trint.c -trint_OBJECTS = trint.o -trint_LDADD = $(LDADD) -trint_DEPENDENCIES = $(top_builddir)/libmpfr.a -trint_LDFLAGS = -tisnan_SOURCES = tisnan.c -tisnan_OBJECTS = tisnan.o -tisnan_LDADD = $(LDADD) -tisnan_DEPENDENCIES = $(top_builddir)/libmpfr.a -tisnan_LDFLAGS = -tget_d_SOURCES = tget_d.c -tget_d_OBJECTS = tget_d.o -tget_d_LDADD = $(LDADD) -tget_d_DEPENDENCIES = $(top_builddir)/libmpfr.a -tget_d_LDFLAGS = -tatan_SOURCES = tatan.c -tatan_OBJECTS = tatan.o -tatan_LDADD = $(LDADD) -tatan_DEPENDENCIES = $(top_builddir)/libmpfr.a -tatan_LDFLAGS = -tcosh_SOURCES = tcosh.c -tcosh_OBJECTS = tcosh.o -tcosh_LDADD = $(LDADD) -tcosh_DEPENDENCIES = $(top_builddir)/libmpfr.a -tcosh_LDFLAGS = -tsinh_SOURCES = tsinh.c -tsinh_OBJECTS = tsinh.o -tsinh_LDADD = $(LDADD) -tsinh_DEPENDENCIES = $(top_builddir)/libmpfr.a -tsinh_LDFLAGS = -ttanh_SOURCES = ttanh.c -ttanh_OBJECTS = ttanh.o -ttanh_LDADD = $(LDADD) -ttanh_DEPENDENCIES = $(top_builddir)/libmpfr.a -ttanh_LDFLAGS = -tacosh_SOURCES = tacosh.c -tacosh_OBJECTS = tacosh.o -tacosh_LDADD = $(LDADD) -tacosh_DEPENDENCIES = $(top_builddir)/libmpfr.a -tacosh_LDFLAGS = -tasinh_SOURCES = tasinh.c -tasinh_OBJECTS = tasinh.o -tasinh_LDADD = $(LDADD) -tasinh_DEPENDENCIES = $(top_builddir)/libmpfr.a -tasinh_LDFLAGS = -tatanh_SOURCES = tatanh.c -tatanh_OBJECTS = tatanh.o -tatanh_LDADD = $(LDADD) -tatanh_DEPENDENCIES = $(top_builddir)/libmpfr.a -tatanh_LDFLAGS = -thyperbolic_SOURCES = thyperbolic.c -thyperbolic_OBJECTS = thyperbolic.o -thyperbolic_LDADD = $(LDADD) -thyperbolic_DEPENDENCIES = $(top_builddir)/libmpfr.a -thyperbolic_LDFLAGS = -texp2_SOURCES = texp2.c -texp2_OBJECTS = texp2.o -texp2_LDADD = $(LDADD) -texp2_DEPENDENCIES = $(top_builddir)/libmpfr.a -texp2_LDFLAGS = -tfactorial_SOURCES = tfactorial.c -tfactorial_OBJECTS = tfactorial.o -tfactorial_LDADD = $(LDADD) -tfactorial_DEPENDENCIES = $(top_builddir)/libmpfr.a -tfactorial_LDFLAGS = -tsub_SOURCES = tsub.c -tsub_OBJECTS = tsub.o -tsub_LDADD = $(LDADD) -tsub_DEPENDENCIES = $(top_builddir)/libmpfr.a -tsub_LDFLAGS = -tasin_SOURCES = tasin.c -tasin_OBJECTS = tasin.o -tasin_LDADD = $(LDADD) -tasin_DEPENDENCIES = $(top_builddir)/libmpfr.a -tasin_LDFLAGS = -tconst_euler_SOURCES = tconst_euler.c -tconst_euler_OBJECTS = tconst_euler.o -tconst_euler_LDADD = $(LDADD) -tconst_euler_DEPENDENCIES = $(top_builddir)/libmpfr.a -tconst_euler_LDFLAGS = -tcos_SOURCES = tcos.c -tcos_OBJECTS = tcos.o -tcos_LDADD = $(LDADD) -tcos_DEPENDENCIES = $(top_builddir)/libmpfr.a -tcos_LDFLAGS = -tsin_SOURCES = tsin.c -tsin_OBJECTS = tsin.o -tsin_LDADD = $(LDADD) -tsin_DEPENDENCIES = $(top_builddir)/libmpfr.a -tsin_LDFLAGS = -ttan_SOURCES = ttan.c -ttan_OBJECTS = ttan.o -ttan_LDADD = $(LDADD) -ttan_DEPENDENCIES = $(top_builddir)/libmpfr.a -ttan_LDFLAGS = -tsub_ui_SOURCES = tsub_ui.c -tsub_ui_OBJECTS = tsub_ui.o -tsub_ui_LDADD = $(LDADD) -tsub_ui_DEPENDENCIES = $(top_builddir)/libmpfr.a -tsub_ui_LDFLAGS = -tset_SOURCES = tset.c -tset_OBJECTS = tset.o -tset_LDADD = $(LDADD) -tset_DEPENDENCIES = $(top_builddir)/libmpfr.a -tset_LDFLAGS = -tlog1p_SOURCES = tlog1p.c -tlog1p_OBJECTS = tlog1p.o -tlog1p_LDADD = $(LDADD) -tlog1p_DEPENDENCIES = $(top_builddir)/libmpfr.a -tlog1p_LDFLAGS = -texpm1_SOURCES = texpm1.c -texpm1_OBJECTS = texpm1.o -texpm1_LDADD = $(LDADD) -texpm1_DEPENDENCIES = $(top_builddir)/libmpfr.a -texpm1_LDFLAGS = -tlog2_SOURCES = tlog2.c -tlog2_OBJECTS = tlog2.o -tlog2_LDADD = $(LDADD) -tlog2_DEPENDENCIES = $(top_builddir)/libmpfr.a -tlog2_LDFLAGS = -tlog10_SOURCES = tlog10.c -tlog10_OBJECTS = tlog10.o -tlog10_LDADD = $(LDADD) -tlog10_DEPENDENCIES = $(top_builddir)/libmpfr.a -tlog10_LDFLAGS = -tui_pow_SOURCES = tui_pow.c -tui_pow_OBJECTS = tui_pow.o -tui_pow_LDADD = $(LDADD) -tui_pow_DEPENDENCIES = $(top_builddir)/libmpfr.a -tui_pow_LDFLAGS = -tpow3_SOURCES = tpow3.c -tpow3_OBJECTS = tpow3.o -tpow3_LDADD = $(LDADD) -tpow3_DEPENDENCIES = $(top_builddir)/libmpfr.a -tpow3_LDFLAGS = -tadd_ui_SOURCES = tadd_ui.c -tadd_ui_OBJECTS = tadd_ui.o -tadd_ui_LDADD = $(LDADD) -tadd_ui_DEPENDENCIES = $(top_builddir)/libmpfr.a -tadd_ui_LDFLAGS = -texceptions_SOURCES = texceptions.c -texceptions_OBJECTS = texceptions.o -texceptions_LDADD = $(LDADD) -texceptions_DEPENDENCIES = $(top_builddir)/libmpfr.a -texceptions_LDFLAGS = -tfma_SOURCES = tfma.c -tfma_OBJECTS = tfma.o -tfma_LDADD = $(LDADD) -tfma_DEPENDENCIES = $(top_builddir)/libmpfr.a -tfma_LDFLAGS = -thypot_SOURCES = thypot.c -thypot_OBJECTS = thypot.o -thypot_LDADD = $(LDADD) -thypot_DEPENDENCIES = $(top_builddir)/libmpfr.a -thypot_LDFLAGS = -tacos_SOURCES = tacos.c -tacos_OBJECTS = tacos.o -tacos_LDADD = $(LDADD) -tacos_DEPENDENCIES = $(top_builddir)/libmpfr.a -tacos_LDFLAGS = -COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -CCLD = $(CC) -LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ -DIST_COMMON = Makefile.am Makefile.in - - -DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) - -TAR = gtar -GZIP_ENV = --best -DEP_FILES = .deps/reuse.P .deps/tabs.P .deps/tacos.P .deps/tacosh.P \ -.deps/tadd.P .deps/tadd_ui.P .deps/tagm.P .deps/tasin.P .deps/tasinh.P \ -.deps/tatan.P .deps/tatanh.P .deps/tcan_round.P .deps/tcmp.P \ -.deps/tcmp2.P .deps/tcmp_ui.P .deps/tconst_euler.P .deps/tconst_log2.P \ -.deps/tconst_pi.P .deps/tcos.P .deps/tcosh.P .deps/tdiv.P \ -.deps/tdiv_ui.P .deps/tdump.P .deps/teq.P .deps/texceptions.P \ -.deps/texp.P .deps/texp2.P .deps/texpm1.P .deps/tfactorial.P \ -.deps/tfma.P .deps/tget_d.P .deps/tget_str.P .deps/thyperbolic.P \ -.deps/thypot.P .deps/tisnan.P .deps/tlog.P .deps/tlog10.P \ -.deps/tlog1p.P .deps/tlog2.P .deps/tmul.P .deps/tmul_2exp.P \ -.deps/tmul_ui.P .deps/tout_str.P .deps/tpow.P .deps/tpow3.P \ -.deps/trandom.P .deps/trint.P .deps/tround_prec.P .deps/tset.P \ -.deps/tset_d.P .deps/tset_f.P .deps/tset_q.P .deps/tset_si.P \ -.deps/tset_str.P .deps/tset_z.P .deps/tsin.P .deps/tsinh.P \ -.deps/tsqrt.P .deps/tsqrt_ui.P .deps/tsub.P .deps/tsub_ui.P \ -.deps/tswap.P .deps/ttan.P .deps/ttanh.P .deps/ttrunc.P .deps/tui_div.P \ -.deps/tui_pow.P .deps/tui_sub.P -SOURCES = reuse.c tabs.c tadd.c tagm.c tcan_round.c tcmp.c tcmp2.c tcmp_ui.c tdiv.c tdiv_ui.c tdump.c teq.c texp.c tget_str.c tlog.c tconst_log2.c tmul.c tmul_2exp.c tmul_ui.c tout_str.c tconst_pi.c tpow.c trandom.c tround_prec.c tset_d.c tset_f.c tset_q.c tset_si.c tset_str.c tset_z.c tsqrt.c tsqrt_ui.c tui_div.c tui_sub.c tswap.c ttrunc.c trint.c tisnan.c tget_d.c tatan.c tcosh.c tsinh.c ttanh.c tacosh.c tasinh.c tatanh.c thyperbolic.c texp2.c tfactorial.c tsub.c tasin.c tconst_euler.c tcos.c tsin.c ttan.c tsub_ui.c tset.c tlog1p.c texpm1.c tlog2.c tlog10.c tui_pow.c tpow3.c tadd_ui.c texceptions.c tfma.c thypot.c tacos.c -OBJECTS = reuse.o tabs.o tadd.o tagm.o tcan_round.o tcmp.o tcmp2.o tcmp_ui.o tdiv.o tdiv_ui.o tdump.o teq.o texp.o tget_str.o tlog.o tconst_log2.o tmul.o tmul_2exp.o tmul_ui.o tout_str.o tconst_pi.o tpow.o trandom.o tround_prec.o tset_d.o tset_f.o tset_q.o tset_si.o tset_str.o tset_z.o tsqrt.o tsqrt_ui.o tui_div.o tui_sub.o tswap.o ttrunc.o trint.o tisnan.o tget_d.o tatan.o tcosh.o tsinh.o ttanh.o tacosh.o tasinh.o tatanh.o thyperbolic.o texp2.o tfactorial.o tsub.o tasin.o tconst_euler.o tcos.o tsin.o ttan.o tsub_ui.o tset.o tlog1p.o texpm1.o tlog2.o tlog10.o tui_pow.o tpow3.o tadd_ui.o texceptions.o tfma.o thypot.o tacos.o - -all: all-redirect -.SUFFIXES: -.SUFFIXES: .S .c .o .s -$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) - cd $(top_srcdir) && $(AUTOMAKE) --gnu tests/Makefile - -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) - cd $(top_builddir) \ - && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status - - -mostlyclean-checkPROGRAMS: - -clean-checkPROGRAMS: - -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS) - -distclean-checkPROGRAMS: - -maintainer-clean-checkPROGRAMS: - -.s.o: - $(COMPILE) -c $< - -.S.o: - $(COMPILE) -c $< - -mostlyclean-compile: - -rm -f *.o core *.core - -clean-compile: - -distclean-compile: - -rm -f *.tab.c - -maintainer-clean-compile: - -reuse: $(reuse_OBJECTS) $(reuse_DEPENDENCIES) - @rm -f reuse - $(LINK) $(reuse_LDFLAGS) $(reuse_OBJECTS) $(reuse_LDADD) $(LIBS) - -tabs: $(tabs_OBJECTS) $(tabs_DEPENDENCIES) - @rm -f tabs - $(LINK) $(tabs_LDFLAGS) $(tabs_OBJECTS) $(tabs_LDADD) $(LIBS) - -tadd: $(tadd_OBJECTS) $(tadd_DEPENDENCIES) - @rm -f tadd - $(LINK) $(tadd_LDFLAGS) $(tadd_OBJECTS) $(tadd_LDADD) $(LIBS) - -tagm: $(tagm_OBJECTS) $(tagm_DEPENDENCIES) - @rm -f tagm - $(LINK) $(tagm_LDFLAGS) $(tagm_OBJECTS) $(tagm_LDADD) $(LIBS) - -tcan_round: $(tcan_round_OBJECTS) $(tcan_round_DEPENDENCIES) - @rm -f tcan_round - $(LINK) $(tcan_round_LDFLAGS) $(tcan_round_OBJECTS) $(tcan_round_LDADD) $(LIBS) - -tcmp: $(tcmp_OBJECTS) $(tcmp_DEPENDENCIES) - @rm -f tcmp - $(LINK) $(tcmp_LDFLAGS) $(tcmp_OBJECTS) $(tcmp_LDADD) $(LIBS) - -tcmp2: $(tcmp2_OBJECTS) $(tcmp2_DEPENDENCIES) - @rm -f tcmp2 - $(LINK) $(tcmp2_LDFLAGS) $(tcmp2_OBJECTS) $(tcmp2_LDADD) $(LIBS) - -tcmp_ui: $(tcmp_ui_OBJECTS) $(tcmp_ui_DEPENDENCIES) - @rm -f tcmp_ui - $(LINK) $(tcmp_ui_LDFLAGS) $(tcmp_ui_OBJECTS) $(tcmp_ui_LDADD) $(LIBS) - -tdiv: $(tdiv_OBJECTS) $(tdiv_DEPENDENCIES) - @rm -f tdiv - $(LINK) $(tdiv_LDFLAGS) $(tdiv_OBJECTS) $(tdiv_LDADD) $(LIBS) - -tdiv_ui: $(tdiv_ui_OBJECTS) $(tdiv_ui_DEPENDENCIES) - @rm -f tdiv_ui - $(LINK) $(tdiv_ui_LDFLAGS) $(tdiv_ui_OBJECTS) $(tdiv_ui_LDADD) $(LIBS) - -tdump: $(tdump_OBJECTS) $(tdump_DEPENDENCIES) - @rm -f tdump - $(LINK) $(tdump_LDFLAGS) $(tdump_OBJECTS) $(tdump_LDADD) $(LIBS) - -teq: $(teq_OBJECTS) $(teq_DEPENDENCIES) - @rm -f teq - $(LINK) $(teq_LDFLAGS) $(teq_OBJECTS) $(teq_LDADD) $(LIBS) - -texp: $(texp_OBJECTS) $(texp_DEPENDENCIES) - @rm -f texp - $(LINK) $(texp_LDFLAGS) $(texp_OBJECTS) $(texp_LDADD) $(LIBS) - -tget_str: $(tget_str_OBJECTS) $(tget_str_DEPENDENCIES) - @rm -f tget_str - $(LINK) $(tget_str_LDFLAGS) $(tget_str_OBJECTS) $(tget_str_LDADD) $(LIBS) - -tlog: $(tlog_OBJECTS) $(tlog_DEPENDENCIES) - @rm -f tlog - $(LINK) $(tlog_LDFLAGS) $(tlog_OBJECTS) $(tlog_LDADD) $(LIBS) - -tconst_log2: $(tconst_log2_OBJECTS) $(tconst_log2_DEPENDENCIES) - @rm -f tconst_log2 - $(LINK) $(tconst_log2_LDFLAGS) $(tconst_log2_OBJECTS) $(tconst_log2_LDADD) $(LIBS) - -tmul: $(tmul_OBJECTS) $(tmul_DEPENDENCIES) - @rm -f tmul - $(LINK) $(tmul_LDFLAGS) $(tmul_OBJECTS) $(tmul_LDADD) $(LIBS) - -tmul_2exp: $(tmul_2exp_OBJECTS) $(tmul_2exp_DEPENDENCIES) - @rm -f tmul_2exp - $(LINK) $(tmul_2exp_LDFLAGS) $(tmul_2exp_OBJECTS) $(tmul_2exp_LDADD) $(LIBS) - -tmul_ui: $(tmul_ui_OBJECTS) $(tmul_ui_DEPENDENCIES) - @rm -f tmul_ui - $(LINK) $(tmul_ui_LDFLAGS) $(tmul_ui_OBJECTS) $(tmul_ui_LDADD) $(LIBS) - -tout_str: $(tout_str_OBJECTS) $(tout_str_DEPENDENCIES) - @rm -f tout_str - $(LINK) $(tout_str_LDFLAGS) $(tout_str_OBJECTS) $(tout_str_LDADD) $(LIBS) - -tconst_pi: $(tconst_pi_OBJECTS) $(tconst_pi_DEPENDENCIES) - @rm -f tconst_pi - $(LINK) $(tconst_pi_LDFLAGS) $(tconst_pi_OBJECTS) $(tconst_pi_LDADD) $(LIBS) - -tpow: $(tpow_OBJECTS) $(tpow_DEPENDENCIES) - @rm -f tpow - $(LINK) $(tpow_LDFLAGS) $(tpow_OBJECTS) $(tpow_LDADD) $(LIBS) - -trandom: $(trandom_OBJECTS) $(trandom_DEPENDENCIES) - @rm -f trandom - $(LINK) $(trandom_LDFLAGS) $(trandom_OBJECTS) $(trandom_LDADD) $(LIBS) - -tround_prec: $(tround_prec_OBJECTS) $(tround_prec_DEPENDENCIES) - @rm -f tround_prec - $(LINK) $(tround_prec_LDFLAGS) $(tround_prec_OBJECTS) $(tround_prec_LDADD) $(LIBS) - -tset_d: $(tset_d_OBJECTS) $(tset_d_DEPENDENCIES) - @rm -f tset_d - $(LINK) $(tset_d_LDFLAGS) $(tset_d_OBJECTS) $(tset_d_LDADD) $(LIBS) - -tset_f: $(tset_f_OBJECTS) $(tset_f_DEPENDENCIES) - @rm -f tset_f - $(LINK) $(tset_f_LDFLAGS) $(tset_f_OBJECTS) $(tset_f_LDADD) $(LIBS) - -tset_q: $(tset_q_OBJECTS) $(tset_q_DEPENDENCIES) - @rm -f tset_q - $(LINK) $(tset_q_LDFLAGS) $(tset_q_OBJECTS) $(tset_q_LDADD) $(LIBS) - -tset_si: $(tset_si_OBJECTS) $(tset_si_DEPENDENCIES) - @rm -f tset_si - $(LINK) $(tset_si_LDFLAGS) $(tset_si_OBJECTS) $(tset_si_LDADD) $(LIBS) - -tset_str: $(tset_str_OBJECTS) $(tset_str_DEPENDENCIES) - @rm -f tset_str - $(LINK) $(tset_str_LDFLAGS) $(tset_str_OBJECTS) $(tset_str_LDADD) $(LIBS) - -tset_z: $(tset_z_OBJECTS) $(tset_z_DEPENDENCIES) - @rm -f tset_z - $(LINK) $(tset_z_LDFLAGS) $(tset_z_OBJECTS) $(tset_z_LDADD) $(LIBS) - -tsqrt: $(tsqrt_OBJECTS) $(tsqrt_DEPENDENCIES) - @rm -f tsqrt - $(LINK) $(tsqrt_LDFLAGS) $(tsqrt_OBJECTS) $(tsqrt_LDADD) $(LIBS) - -tsqrt_ui: $(tsqrt_ui_OBJECTS) $(tsqrt_ui_DEPENDENCIES) - @rm -f tsqrt_ui - $(LINK) $(tsqrt_ui_LDFLAGS) $(tsqrt_ui_OBJECTS) $(tsqrt_ui_LDADD) $(LIBS) - -tui_div: $(tui_div_OBJECTS) $(tui_div_DEPENDENCIES) - @rm -f tui_div - $(LINK) $(tui_div_LDFLAGS) $(tui_div_OBJECTS) $(tui_div_LDADD) $(LIBS) - -tui_sub: $(tui_sub_OBJECTS) $(tui_sub_DEPENDENCIES) - @rm -f tui_sub - $(LINK) $(tui_sub_LDFLAGS) $(tui_sub_OBJECTS) $(tui_sub_LDADD) $(LIBS) - -tswap: $(tswap_OBJECTS) $(tswap_DEPENDENCIES) - @rm -f tswap - $(LINK) $(tswap_LDFLAGS) $(tswap_OBJECTS) $(tswap_LDADD) $(LIBS) - -ttrunc: $(ttrunc_OBJECTS) $(ttrunc_DEPENDENCIES) - @rm -f ttrunc - $(LINK) $(ttrunc_LDFLAGS) $(ttrunc_OBJECTS) $(ttrunc_LDADD) $(LIBS) - -trint: $(trint_OBJECTS) $(trint_DEPENDENCIES) - @rm -f trint - $(LINK) $(trint_LDFLAGS) $(trint_OBJECTS) $(trint_LDADD) $(LIBS) - -tisnan: $(tisnan_OBJECTS) $(tisnan_DEPENDENCIES) - @rm -f tisnan - $(LINK) $(tisnan_LDFLAGS) $(tisnan_OBJECTS) $(tisnan_LDADD) $(LIBS) - -tget_d: $(tget_d_OBJECTS) $(tget_d_DEPENDENCIES) - @rm -f tget_d - $(LINK) $(tget_d_LDFLAGS) $(tget_d_OBJECTS) $(tget_d_LDADD) $(LIBS) - -tatan: $(tatan_OBJECTS) $(tatan_DEPENDENCIES) - @rm -f tatan - $(LINK) $(tatan_LDFLAGS) $(tatan_OBJECTS) $(tatan_LDADD) $(LIBS) - -tcosh: $(tcosh_OBJECTS) $(tcosh_DEPENDENCIES) - @rm -f tcosh - $(LINK) $(tcosh_LDFLAGS) $(tcosh_OBJECTS) $(tcosh_LDADD) $(LIBS) - -tsinh: $(tsinh_OBJECTS) $(tsinh_DEPENDENCIES) - @rm -f tsinh - $(LINK) $(tsinh_LDFLAGS) $(tsinh_OBJECTS) $(tsinh_LDADD) $(LIBS) - -ttanh: $(ttanh_OBJECTS) $(ttanh_DEPENDENCIES) - @rm -f ttanh - $(LINK) $(ttanh_LDFLAGS) $(ttanh_OBJECTS) $(ttanh_LDADD) $(LIBS) - -tacosh: $(tacosh_OBJECTS) $(tacosh_DEPENDENCIES) - @rm -f tacosh - $(LINK) $(tacosh_LDFLAGS) $(tacosh_OBJECTS) $(tacosh_LDADD) $(LIBS) - -tasinh: $(tasinh_OBJECTS) $(tasinh_DEPENDENCIES) - @rm -f tasinh - $(LINK) $(tasinh_LDFLAGS) $(tasinh_OBJECTS) $(tasinh_LDADD) $(LIBS) - -tatanh: $(tatanh_OBJECTS) $(tatanh_DEPENDENCIES) - @rm -f tatanh - $(LINK) $(tatanh_LDFLAGS) $(tatanh_OBJECTS) $(tatanh_LDADD) $(LIBS) - -thyperbolic: $(thyperbolic_OBJECTS) $(thyperbolic_DEPENDENCIES) - @rm -f thyperbolic - $(LINK) $(thyperbolic_LDFLAGS) $(thyperbolic_OBJECTS) $(thyperbolic_LDADD) $(LIBS) - -texp2: $(texp2_OBJECTS) $(texp2_DEPENDENCIES) - @rm -f texp2 - $(LINK) $(texp2_LDFLAGS) $(texp2_OBJECTS) $(texp2_LDADD) $(LIBS) - -tfactorial: $(tfactorial_OBJECTS) $(tfactorial_DEPENDENCIES) - @rm -f tfactorial - $(LINK) $(tfactorial_LDFLAGS) $(tfactorial_OBJECTS) $(tfactorial_LDADD) $(LIBS) - -tsub: $(tsub_OBJECTS) $(tsub_DEPENDENCIES) - @rm -f tsub - $(LINK) $(tsub_LDFLAGS) $(tsub_OBJECTS) $(tsub_LDADD) $(LIBS) - -tasin: $(tasin_OBJECTS) $(tasin_DEPENDENCIES) - @rm -f tasin - $(LINK) $(tasin_LDFLAGS) $(tasin_OBJECTS) $(tasin_LDADD) $(LIBS) - -tconst_euler: $(tconst_euler_OBJECTS) $(tconst_euler_DEPENDENCIES) - @rm -f tconst_euler - $(LINK) $(tconst_euler_LDFLAGS) $(tconst_euler_OBJECTS) $(tconst_euler_LDADD) $(LIBS) - -tcos: $(tcos_OBJECTS) $(tcos_DEPENDENCIES) - @rm -f tcos - $(LINK) $(tcos_LDFLAGS) $(tcos_OBJECTS) $(tcos_LDADD) $(LIBS) - -tsin: $(tsin_OBJECTS) $(tsin_DEPENDENCIES) - @rm -f tsin - $(LINK) $(tsin_LDFLAGS) $(tsin_OBJECTS) $(tsin_LDADD) $(LIBS) - -ttan: $(ttan_OBJECTS) $(ttan_DEPENDENCIES) - @rm -f ttan - $(LINK) $(ttan_LDFLAGS) $(ttan_OBJECTS) $(ttan_LDADD) $(LIBS) - -tsub_ui: $(tsub_ui_OBJECTS) $(tsub_ui_DEPENDENCIES) - @rm -f tsub_ui - $(LINK) $(tsub_ui_LDFLAGS) $(tsub_ui_OBJECTS) $(tsub_ui_LDADD) $(LIBS) - -tset: $(tset_OBJECTS) $(tset_DEPENDENCIES) - @rm -f tset - $(LINK) $(tset_LDFLAGS) $(tset_OBJECTS) $(tset_LDADD) $(LIBS) - -tlog1p: $(tlog1p_OBJECTS) $(tlog1p_DEPENDENCIES) - @rm -f tlog1p - $(LINK) $(tlog1p_LDFLAGS) $(tlog1p_OBJECTS) $(tlog1p_LDADD) $(LIBS) - -texpm1: $(texpm1_OBJECTS) $(texpm1_DEPENDENCIES) - @rm -f texpm1 - $(LINK) $(texpm1_LDFLAGS) $(texpm1_OBJECTS) $(texpm1_LDADD) $(LIBS) - -tlog2: $(tlog2_OBJECTS) $(tlog2_DEPENDENCIES) - @rm -f tlog2 - $(LINK) $(tlog2_LDFLAGS) $(tlog2_OBJECTS) $(tlog2_LDADD) $(LIBS) - -tlog10: $(tlog10_OBJECTS) $(tlog10_DEPENDENCIES) - @rm -f tlog10 - $(LINK) $(tlog10_LDFLAGS) $(tlog10_OBJECTS) $(tlog10_LDADD) $(LIBS) - -tui_pow: $(tui_pow_OBJECTS) $(tui_pow_DEPENDENCIES) - @rm -f tui_pow - $(LINK) $(tui_pow_LDFLAGS) $(tui_pow_OBJECTS) $(tui_pow_LDADD) $(LIBS) - -tpow3: $(tpow3_OBJECTS) $(tpow3_DEPENDENCIES) - @rm -f tpow3 - $(LINK) $(tpow3_LDFLAGS) $(tpow3_OBJECTS) $(tpow3_LDADD) $(LIBS) - -tadd_ui: $(tadd_ui_OBJECTS) $(tadd_ui_DEPENDENCIES) - @rm -f tadd_ui - $(LINK) $(tadd_ui_LDFLAGS) $(tadd_ui_OBJECTS) $(tadd_ui_LDADD) $(LIBS) - -texceptions: $(texceptions_OBJECTS) $(texceptions_DEPENDENCIES) - @rm -f texceptions - $(LINK) $(texceptions_LDFLAGS) $(texceptions_OBJECTS) $(texceptions_LDADD) $(LIBS) - -tfma: $(tfma_OBJECTS) $(tfma_DEPENDENCIES) - @rm -f tfma - $(LINK) $(tfma_LDFLAGS) $(tfma_OBJECTS) $(tfma_LDADD) $(LIBS) - -thypot: $(thypot_OBJECTS) $(thypot_DEPENDENCIES) - @rm -f thypot - $(LINK) $(thypot_LDFLAGS) $(thypot_OBJECTS) $(thypot_LDADD) $(LIBS) - -tacos: $(tacos_OBJECTS) $(tacos_DEPENDENCIES) - @rm -f tacos - $(LINK) $(tacos_LDFLAGS) $(tacos_OBJECTS) $(tacos_LDADD) $(LIBS) - -tags: TAGS - -ID: $(HEADERS) $(SOURCES) $(LISP) - list='$(SOURCES) $(HEADERS)'; \ - unique=`for i in $$list; do echo $$i; done | \ - awk ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - here=`pwd` && cd $(srcdir) \ - && mkid -f$$here/ID $$unique $(LISP) - -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) - tags=; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS)'; \ - unique=`for i in $$list; do echo $$i; done | \ - awk ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ - || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) - -mostlyclean-tags: - -clean-tags: - -distclean-tags: - -rm -f TAGS ID - -maintainer-clean-tags: - -distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) - -subdir = tests - -distdir: $(DISTFILES) - here=`cd $(top_builddir) && pwd`; \ - top_distdir=`cd $(top_distdir) && pwd`; \ - distdir=`cd $(distdir) && pwd`; \ - cd $(top_srcdir) \ - && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu tests/Makefile - @for file in $(DISTFILES); do \ - d=$(srcdir); \ - if test -d $$d/$$file; then \ - cp -pr $$d/$$file $(distdir)/$$file; \ - else \ - test -f $(distdir)/$$file \ - || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ - || cp -p $$d/$$file $(distdir)/$$file || :; \ - fi; \ - done - -DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :) - --include $(DEP_FILES) - -mostlyclean-depend: - -clean-depend: - -distclean-depend: - -rm -rf .deps - -maintainer-clean-depend: - -%.o: %.c - @echo '$(COMPILE) -c $<'; \ - $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $< - @-cp .deps/$(*F).pp .deps/$(*F).P; \ - tr ' ' '\012' < .deps/$(*F).pp \ - | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ - >> .deps/$(*F).P; \ - rm .deps/$(*F).pp - -%.lo: %.c - @echo '$(LTCOMPILE) -c $<'; \ - $(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $< - @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \ - < .deps/$(*F).pp > .deps/$(*F).P; \ - tr ' ' '\012' < .deps/$(*F).pp \ - | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ - >> .deps/$(*F).P; \ - rm -f .deps/$(*F).pp -info-am: -info: info-am -dvi-am: -dvi: dvi-am -check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) -check: check-am -installcheck-am: -installcheck: installcheck-am -install-exec-am: -install-exec: install-exec-am - -install-data-am: -install-data: install-data-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am -install: install-am -uninstall-am: -uninstall: uninstall-am -all-am: Makefile -all-redirect: all-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install -installdirs: - - -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -rm -f Makefile $(CONFIG_CLEAN_FILES) - -rm -f config.cache config.log stamp-h stamp-h[0-9]* - -maintainer-clean-generic: -mostlyclean-am: mostlyclean-checkPROGRAMS mostlyclean-compile \ - mostlyclean-tags mostlyclean-depend mostlyclean-generic - -mostlyclean: mostlyclean-am - -clean-am: clean-checkPROGRAMS clean-compile clean-tags clean-depend \ - clean-generic mostlyclean-am - -clean: clean-am - -distclean-am: distclean-checkPROGRAMS distclean-compile distclean-tags \ - distclean-depend distclean-generic clean-am - -distclean: distclean-am - -maintainer-clean-am: maintainer-clean-checkPROGRAMS \ - maintainer-clean-compile maintainer-clean-tags \ - maintainer-clean-depend maintainer-clean-generic \ - distclean-am - @echo "This command is intended for maintainers to use;" - @echo "it deletes files that may require special tools to rebuild." - -maintainer-clean: maintainer-clean-am - -.PHONY: mostlyclean-checkPROGRAMS distclean-checkPROGRAMS \ -clean-checkPROGRAMS maintainer-clean-checkPROGRAMS mostlyclean-compile \ -distclean-compile clean-compile maintainer-clean-compile tags \ -mostlyclean-tags distclean-tags clean-tags maintainer-clean-tags \ -distdir mostlyclean-depend distclean-depend clean-depend \ -maintainer-clean-depend info-am info dvi-am dvi check check-am \ -installcheck-am installcheck install-exec-am install-exec \ -install-data-am install-data install-am install uninstall-am uninstall \ -all-redirect all-am all installdirs mostlyclean-generic \ -distclean-generic clean-generic maintainer-clean-generic clean \ -mostlyclean distclean maintainer-clean - - -../libmpfr.a: - cd $(top_srcdir); make libmpfr.a - -check: all - for i in $(check_PROGRAMS); do echo Testing $$i ; ./$$i || echo "### $$i failed ###"; done - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/tests/mpf_compat.h b/tests/mpf_compat.h index 04f047efd..07ddfcf33 100644 --- a/tests/mpf_compat.h +++ b/tests/mpf_compat.h @@ -1,6 +1,6 @@ /* Test compatibility mpf-mpfr. -Copyright 2003 Free Software Foundation. +Copyright 2003, 2004 Free Software Foundation. This file is part of the MPFR Library. @@ -160,19 +160,28 @@ main () /* Input and Output Functions */ f = fopen ("/dev/null", "w"); - mpf_out_str (f, 10, 10, x); - fclose (f); + if (f != NULL) + { + mpf_out_str (f, 10, 10, x); + fclose (f); + } mpf_set_prec (x, 15); mpf_set_prec (y, 15); + /* We may use src_fopen instead of fopen, but it is defined + in mpfr-test, and not in mpfr.h and gmp.h, and we want + to test theses includes files. */ f = fopen ("inp_str.data", "r"); - i = mpf_inp_str (x, f, 10); - if ((i == 0) || mpf_cmp_ui (x, 31415)) + if (f != NULL) { - printf ("Error in reading 1st line from file inp_str.data\n"); - exit (1); + i = mpf_inp_str (x, f, 10); + if ((i == 0) || mpf_cmp_ui (x, 31415)) + { + printf ("Error in reading 1st line from file inp_str.data\n"); + exit (1); + } + fclose (f); } - fclose (f); /* Miscellaneous Functions */ diff --git a/tests/tabs.c b/tests/tabs.c index ba65061b3..70a5400d8 100644 --- a/tests/tabs.c +++ b/tests/tabs.c @@ -1,6 +1,6 @@ /* Test file for mpfr_abs. -Copyright 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +Copyright 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -30,7 +30,7 @@ check_inexact (void) { mp_prec_t p, q; mpfr_t x, y, absx; - mp_rnd_t rnd; + int rnd; int inexact, cmp; mpfr_init (x); @@ -54,7 +54,7 @@ check_inexact (void) mpfr_set_prec (y, q); for (rnd = 0; rnd < GMP_RND_MAX; rnd++) { - inexact = mpfr_abs (y, x, rnd); + inexact = mpfr_abs (y, x, (mp_rnd_t) rnd); cmp = mpfr_cmp (y, absx); if (((inexact == 0) && (cmp != 0)) || ((inexact > 0) && (cmp <= 0)) || @@ -138,7 +138,7 @@ check_cmp(int argc, char *argv[]) mpfr_random(x); MPFR_SET_SIGN(x, sign); rnd = RND_RAND(); - mpfr_abs(y, x, rnd); + mpfr_abs(y, x, (mp_rnd_t) rnd); MPFR_SET_POS(x); if (mpfr_cmp(x,y)) { diff --git a/tests/tacos.c b/tests/tacos.c index e1df1cb9b..14c20efb9 100644 --- a/tests/tacos.c +++ b/tests/tacos.c @@ -1,6 +1,6 @@ /* Test file for mpfr_acos. -Copyright 2001, 2002, 2003, 2004 Free Software Foundation. +Copyright 2001, 2002, 2003, 2004, 2005 Free Software Foundation. Contributed by Mathieu Dutour. This file is part of the MPFR Library. @@ -75,8 +75,8 @@ special_overflow (void) { mpfr_t x, y; - mpfr_set_emin (-125); - mpfr_set_emax (128); + set_emin (-125); + set_emax (128); mpfr_init2 (x, 24); mpfr_init2 (y, 48); mpfr_set_str_binary (x, "0.101100100000000000110100E0"); @@ -90,15 +90,15 @@ special_overflow (void) } mpfr_clear (y); mpfr_clear (x); - mpfr_set_emin (MPFR_EMIN_MIN); - mpfr_set_emax (MPFR_EMAX_MAX); + set_emin (MPFR_EMIN_MIN); + set_emax (MPFR_EMAX_MAX); } int main (void) { mpfr_t x, y; - mp_rnd_t r; + int r; tests_start_mpfr (); @@ -145,13 +145,13 @@ main (void) for (r = 0; r < GMP_RND_MAX; r++) { mpfr_set_ui (x, 0, GMP_RNDN); /* exact */ - mpfr_acos (y, x, r); - mpfr_const_pi (x, r); + mpfr_acos (y, x, (mp_rnd_t) r); + mpfr_const_pi (x, (mp_rnd_t) r); mpfr_div_2exp (x, x, 1, GMP_RNDN); /* exact */ if (mpfr_cmp (x, y)) { printf ("Error: acos(0) != Pi/2 for rnd=%s\n", - mpfr_print_rnd_mode (r)); + mpfr_print_rnd_mode ((mp_rnd_t) r)); exit (1); } } @@ -160,12 +160,12 @@ main (void) for (r = 0; r < GMP_RND_MAX; r++) { mpfr_set_si (x, -1, GMP_RNDN); /* exact */ - mpfr_acos (y, x, r); - mpfr_const_pi (x, r); + mpfr_acos (y, x, (mp_rnd_t) r); + mpfr_const_pi (x, (mp_rnd_t) r); if (mpfr_cmp (x, y)) { printf ("Error: acos(1) != Pi for rnd=%s\n", - mpfr_print_rnd_mode (r)); + mpfr_print_rnd_mode ((mp_rnd_t) r)); exit (1); } } diff --git a/tests/tadd.c b/tests/tadd.c index 1b908095d..161ad9b64 100644 --- a/tests/tadd.c +++ b/tests/tadd.c @@ -1,6 +1,6 @@ /* Test file for mpfr_add and mpfr_sub. -Copyright 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation. +Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation. This file is part of the MPFR Library. @@ -509,7 +509,7 @@ check_inexact (void) abs(EXP(x)-EXP(u)) + max(prec(x), prec(u)) + 1 */ pz = pz + MAX(MPFR_PREC(x), MPFR_PREC(u)) + 1; mpfr_set_prec (z, pz); - rnd = RND_RAND(); + rnd = (mp_rnd_t) RND_RAND(); if (test_add (z, x, u, rnd)) { printf ("z <- x + u should be exact\n"); @@ -519,7 +519,7 @@ check_inexact (void) exit (1); } { - rnd = RND_RAND(); + rnd = (mp_rnd_t) RND_RAND(); inexact = test_add (y, x, u, rnd); cmp = mpfr_cmp (y, z); if (((inexact == 0) && (cmp != 0)) || @@ -614,7 +614,7 @@ check_overflow (void) { mpfr_t a, b, c; mp_prec_t prec_a; - mp_rnd_t r; + int r; mpfr_init2 (a, 256); mpfr_init2 (b, 256); @@ -629,7 +629,7 @@ check_overflow (void) { mpfr_set_prec (a, prec_a); mpfr_clear_overflow (); - test_add (a, b, c, r); + test_add (a, b, c, (mp_rnd_t) r); if (!mpfr_overflow_p ()) { printf ("No overflow in check_overflow\n"); @@ -695,7 +695,7 @@ check_1111 (void) mpfr_add (c, c, one, GMP_RNDN); diff = (randlimb () % (2*m)) - m; mpfr_mul_2si (c, c, diff, GMP_RNDN); - rnd_mode = RND_RAND (); + rnd_mode = (mp_rnd_t) RND_RAND (); inex_a = test_add (a, b, c, rnd_mode); mpfr_init2 (s, MPFR_PREC_MIN + 2*m); inex_s = mpfr_add (s, b, c, GMP_RNDN); /* exact */ @@ -740,15 +740,15 @@ check_1minuseps (void) 0, 1, 2, 3, 4, 29, 30, 31, 32, 33, 34, 35, 61, 62, 63, 64, 65, 66, 67 }; mpfr_t a, b, c; - int ia, ib, ic; + unsigned int ia, ib, ic; mpfr_init2 (c, MPFR_PREC_MIN); - for (ia = 0; ia < numberof(prec_a); ia++) + for (ia = 0; ia < numberof (prec_a); ia++) for (ib = 0; ib < numberof(supp_b); ib++) { mp_prec_t prec_b; - mp_rnd_t rnd_mode; + int rnd_mode; prec_b = prec_a[ia] + supp_b[ib]; @@ -767,23 +767,23 @@ check_1minuseps (void) mpfr_set_ui (c, 1, GMP_RNDN); mpfr_div_ui (c, c, prec_a[ia] + supp_b[ic], GMP_RNDN); - inex_a = test_add (a, b, c, rnd_mode); + inex_a = test_add (a, b, c, (mp_rnd_t) rnd_mode); mpfr_init2 (s, 256); inex_s = mpfr_add (s, b, c, GMP_RNDN); /* exact */ if (inex_s) { printf ("check_1minuseps: result should have been exact " - "(ia = %d, ib = %d, ic = %d)\n", ia, ib, ic); + "(ia = %u, ib = %u, ic = %u)\n", ia, ib, ic); exit (1); } - inex_s = mpfr_prec_round (s, prec_a[ia], rnd_mode); + inex_s = mpfr_prec_round (s, prec_a[ia], (mp_rnd_t) rnd_mode); if ((inex_a < 0 && inex_s >= 0) || (inex_a == 0 && inex_s != 0) || (inex_a > 0 && inex_s <= 0) || !mpfr_equal_p (a, s)) { printf ("check_1minuseps: results are different.\n"); - printf ("ia = %d, ib = %d, ic = %d\n", ia, ib, ic); + printf ("ia = %u, ib = %u, ic = %u\n", ia, ib, ic); exit (1); } mpfr_clear (s); diff --git a/tests/tadd1sp.c b/tests/tadd1sp.c index 804e700d3..52a7f9bc2 100644 --- a/tests/tadd1sp.c +++ b/tests/tadd1sp.c @@ -1,6 +1,6 @@ /* Test file for mpfr_add1sp. -Copyright 2004 Free Software Foundation. +Copyright 2004, 2005 Free Software Foundation. This file is part of the MPFR Library. @@ -32,11 +32,11 @@ check_overflow (void) { mpfr_t x, y, z1, z2; - mpfr_set_emin (-1021); - mpfr_set_emax (1024); + set_emin (-1021); + set_emax (1024); mpfr_inits (x, y, z1, z2, NULL); - + mpfr_set_str1 (x, "8.00468257869324898448e+307"); mpfr_set_str1 (y, "7.44784712422708645156e+307"); mpfr_add1sp (z1, x, y, GMP_RNDN); @@ -67,7 +67,7 @@ int main(void) #define STD_ERROR \ {\ printf("ERROR: for %s and p=%lu and i=%d:\nB=",\ - mpfr_print_rnd_mode(r), p, i);\ + mpfr_print_rnd_mode ((mp_rnd_t) r), p, i);\ mpfr_print_binary(b);\ printf("\nC="); mpfr_print_binary(c);\ printf("\nadd1 : "); mpfr_print_binary(a1);\ @@ -79,49 +79,50 @@ int main(void) #define STD_ERROR2 \ {\ printf("ERROR: Wrong inexact flag for %s and p=%lu and i=%d:\nB=",\ - mpfr_print_rnd_mode(r), p, i);\ + mpfr_print_rnd_mode ((mp_rnd_t) r), p, i);\ mpfr_print_binary(b);\ printf("\nC="); mpfr_print_binary(c);\ printf("\nA="); mpfr_print_binary(a1);\ printf("\nAdd1: %d. Add1sp: %d\n", \ - inexact1, inexact2); \ + inexact1, inexact2); \ exit(1);\ } #define SET_PREC(_p) \ - { p = _p; \ - mpfr_set_prec(a1, _p); mpfr_set_prec(a2, _p); \ - mpfr_set_prec(b, _p); mpfr_set_prec(c, _p); \ - } + { \ + p = _p; \ + mpfr_set_prec(a1, _p); mpfr_set_prec(a2, _p); \ + mpfr_set_prec(b, _p); mpfr_set_prec(c, _p); \ + } void check_random(mp_prec_t p) { mpfr_t a1,b,c,a2; - mp_rnd_t r; + int r; int i, inexact1, inexact2; mpfr_inits2(p, a1,b,c,a2, NULL); - for(i = 0 ; i < 500 ; i++) + for (i = 0 ; i < 500 ; i++) { mpfr_random(b); mpfr_random(c); if (MPFR_IS_PURE_FP(b) && MPFR_IS_PURE_FP(c)) - { - if (MPFR_GET_EXP(b) < MPFR_GET_EXP(c)) - mpfr_swap(b, c); - if (MPFR_IS_PURE_FP(b) && MPFR_IS_PURE_FP(c)) - for(r = 0 ; r < GMP_RND_MAX ; r++) - { - inexact1 = mpfr_add1(a1, b, c, r); - inexact2 = mpfr_add1sp(a2, b, c, r); - if (mpfr_cmp(a1, a2)) - STD_ERROR; - if (inexact1 != inexact2) - STD_ERROR2; - } - } + { + if (MPFR_GET_EXP(b) < MPFR_GET_EXP(c)) + mpfr_swap(b, c); + if (MPFR_IS_PURE_FP(b) && MPFR_IS_PURE_FP(c)) + for (r = 0 ; r < GMP_RND_MAX ; r++) + { + inexact1 = mpfr_add1(a1, b, c, (mp_rnd_t) r); + inexact2 = mpfr_add1sp(a2, b, c, (mp_rnd_t) r); + if (mpfr_cmp(a1, a2)) + STD_ERROR; + if (inexact1 != inexact2) + STD_ERROR2; + } + } } mpfr_clears(a1,a2,b,c,NULL); @@ -130,32 +131,32 @@ void check_random(mp_prec_t p) void check_special(void) { mpfr_t a1,a2,b,c; - mp_rnd_t r; + int r; mpfr_prec_t p; int i = -1, inexact1, inexact2; mpfr_inits(a1,a2,b,c,NULL); - for(r = 0 ; r < GMP_RND_MAX ; r++) + for (r = 0 ; r < GMP_RND_MAX ; r++) { SET_PREC(53); mpfr_set_str1 (b, "1@100"); mpfr_set_str1 (c, "1@1"); - inexact1 = mpfr_add1(a1, b, c, r); - inexact2 = mpfr_add1sp(a2, b, c, r); + inexact1 = mpfr_add1(a1, b, c, (mp_rnd_t) r); + inexact2 = mpfr_add1sp(a2, b, c, (mp_rnd_t) r); if (mpfr_cmp(a1, a2)) - STD_ERROR; + STD_ERROR; if (inexact1 != inexact2) - STD_ERROR2; + STD_ERROR2; mpfr_set_str_binary (b, "1E53"); mpfr_set_str_binary (c, "1E0"); - inexact1 = mpfr_add1(a1, b, c, r); - inexact2 = mpfr_add1sp(a2, b, c, r); + inexact1 = mpfr_add1(a1, b, c, (mp_rnd_t) r); + inexact2 = mpfr_add1sp(a2, b, c, (mp_rnd_t) r); if (mpfr_cmp(a1, a2)) STD_ERROR; if (inexact1 != inexact2) STD_ERROR2; } - mpfr_clears(a1,a2,b,c,NULL); + mpfr_clears(a1,a2,b,c,NULL); } diff --git a/tests/tadd_ui.c b/tests/tadd_ui.c index 059755669..e7ae1c4d9 100644 --- a/tests/tadd_ui.c +++ b/tests/tadd_ui.c @@ -1,6 +1,6 @@ /* Test file for mpfr_add_ui -Copyright 2000, 2001, 2002, 2003, 2004 Free Software Foundation. +Copyright 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation. This file is part of the MPFR Library. @@ -27,7 +27,7 @@ MA 02111-1307, USA. */ /* checks that x+y gives the right results with 53 bits of precision */ static void -check3 (const char *xs, unsigned long y, unsigned int rnd_mode, const char *zs) +check3 (const char *xs, unsigned long y, mp_rnd_t rnd_mode, const char *zs) { mpfr_t xx, zz; diff --git a/tests/tasin.c b/tests/tasin.c index 12bdaf579..57e3d7e21 100644 --- a/tests/tasin.c +++ b/tests/tasin.c @@ -1,6 +1,6 @@ /* Test file for mpfr_asin. -Copyright 2001, 2002, 2003, 2004 Free Software Foundation. +Copyright 2001, 2002, 2003, 2004, 2005 Free Software Foundation. Original version by Mathieu Dutour. This file is part of the MPFR Library. @@ -32,7 +32,7 @@ static void special (void) { mpfr_t x, y; - mp_rnd_t r; + int r; mpfr_init (x); mpfr_init (y); @@ -98,13 +98,13 @@ special (void) for (r = 0; r < GMP_RND_MAX; r++) { mpfr_set_ui (x, 1, GMP_RNDN); /* exact */ - mpfr_asin (y, x, r); - mpfr_const_pi (x, r); + mpfr_asin (y, x, (mp_rnd_t) r); + mpfr_const_pi (x, (mp_rnd_t) r); mpfr_div_2exp (x, x, 1, GMP_RNDN); /* exact */ if (mpfr_cmp (x, y)) { printf ("Error: asin(1) != Pi/2 for rnd=%s\n", - mpfr_print_rnd_mode (r)); + mpfr_print_rnd_mode ((mp_rnd_t) r)); exit (1); } } @@ -113,14 +113,14 @@ special (void) for (r = 0; r < GMP_RND_MAX; r++) { mpfr_set_si (x, -1, GMP_RNDN); /* exact */ - mpfr_asin (y, x, r); - mpfr_const_pi (x, MPFR_INVERT_RND(r)); + mpfr_asin (y, x, (mp_rnd_t) r); + mpfr_const_pi (x, MPFR_INVERT_RND((mp_rnd_t) r)); mpfr_neg (x, x, GMP_RNDN); /* exact */ mpfr_div_2exp (x, x, 1, GMP_RNDN); /* exact */ if (mpfr_cmp (x, y)) { printf ("Error: asin(-1) != -Pi/2 for rnd=%s\n", - mpfr_print_rnd_mode (r)); + mpfr_print_rnd_mode ((mp_rnd_t) r)); exit (1); } } @@ -157,8 +157,8 @@ special_overflow (void) { mpfr_t x, y; - mpfr_set_emin (-125); - mpfr_set_emax (128); + set_emin (-125); + set_emax (128); mpfr_init2 (x, 24); mpfr_init2 (y, 48); mpfr_set_str_binary (x, "0.101100100000000000110100E0"); @@ -172,8 +172,8 @@ special_overflow (void) } mpfr_clear (y); mpfr_clear (x); - mpfr_set_emin (MPFR_EMIN_MIN); - mpfr_set_emax (MPFR_EMAX_MAX); + set_emin (MPFR_EMIN_MIN); + set_emax (MPFR_EMAX_MAX); } int diff --git a/tests/tatan.c b/tests/tatan.c index f0f146ad7..53f528929 100644 --- a/tests/tatan.c +++ b/tests/tatan.c @@ -1,6 +1,6 @@ /* Test file for mpfr_atan. -Copyright 2001, 2002, 2003, 2004 Free Software Foundation. +Copyright 2001, 2002, 2003, 2004, 2005 Free Software Foundation. Written by Paul Zimmermann, INRIA Lorraine. This file is part of the MPFR Library. @@ -29,7 +29,7 @@ static void special (void) { mpfr_t x, y, z; - mp_rnd_t r; + int r; mpfr_init2 (x, 53); mpfr_init2 (y, 53); @@ -55,12 +55,13 @@ special (void) for (r = 0; r < GMP_RND_MAX ; r++) { mpfr_set_inf (x, 1); - mpfr_atan (y, x, r); - mpfr_const_pi (x, r); - mpfr_div_2exp (x, x, 1, r); + mpfr_atan (y, x, (mp_rnd_t) r); + mpfr_const_pi (x, (mp_rnd_t) r); + mpfr_div_2exp (x, x, 1, (mp_rnd_t) r); if (mpfr_cmp (x, y)) { - printf ("Error: mpfr_atan(+Inf), rnd=%s\n", mpfr_print_rnd_mode (r)); + printf ("Error: mpfr_atan(+Inf), rnd=%s\n", + mpfr_print_rnd_mode ((mp_rnd_t) r)); exit (1); } } @@ -69,13 +70,14 @@ special (void) for (r = 0; r < GMP_RND_MAX ; r++) { mpfr_set_inf (x, -1); - mpfr_atan (y, x, r); - mpfr_const_pi (x, MPFR_INVERT_RND(r)); - mpfr_neg (x, x, r); - mpfr_div_2exp (x, x, 1, r); + mpfr_atan (y, x, (mp_rnd_t) r); + mpfr_const_pi (x, MPFR_INVERT_RND((mp_rnd_t) r)); + mpfr_neg (x, x, (mp_rnd_t) r); + mpfr_div_2exp (x, x, 1, (mp_rnd_t) r); if (mpfr_cmp (x, y)) { - printf ("Error: mpfr_atan(-Inf), rnd=%s\n", mpfr_print_rnd_mode (r)); + printf ("Error: mpfr_atan(-Inf), rnd=%s\n", + mpfr_print_rnd_mode ((mp_rnd_t) r)); exit (1); } } @@ -157,8 +159,8 @@ special_overflow (void) { mpfr_t x, y; - mpfr_set_emin (-125); - mpfr_set_emax (128); + set_emin (-125); + set_emax (128); mpfr_init2 (x, 24); mpfr_init2 (y, 48); mpfr_set_str_binary (x, "0.101101010001001101111010E0"); @@ -172,8 +174,8 @@ special_overflow (void) } mpfr_clear (y); mpfr_clear (x); - mpfr_set_emin (MPFR_EMIN_MIN); - mpfr_set_emax (MPFR_EMAX_MAX); + set_emin (MPFR_EMIN_MIN); + set_emax (MPFR_EMAX_MAX); } int diff --git a/tests/tcan_round.c b/tests/tcan_round.c index e0b1d0119..d2679b43e 100644 --- a/tests/tcan_round.c +++ b/tests/tcan_round.c @@ -1,6 +1,6 @@ /* Test file for mpfr_can_round. -Copyright 1999, 2001, 2002, 2003 Free Software Foundation, Inc. +Copyright 1999, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -62,10 +62,10 @@ main (void) for (i = 30; i < 99; i++) for (j = 30; j < 99; j++) { - mp_rnd_t r1, r2; + int r1, r2; for (r1 = 0; r1 < GMP_RND_MAX ; r1++) for (r2 = 0; r2 < GMP_RND_MAX ; r2++) - mpfr_can_round (x, i, r1, r2, j); /* test for assertions */ + mpfr_can_round (x, i, (mp_rnd_t) r1, (mp_rnd_t) r2, j); /* test for assertions */ } mpfr_clear (x); diff --git a/tests/tcbrt.c b/tests/tcbrt.c index bac5b7418..ac64e01ba 100644 --- a/tests/tcbrt.c +++ b/tests/tcbrt.c @@ -1,6 +1,6 @@ /* Test file for mpfr_cbrt. -Copyright 2002, 2003, 2004 Free Software Foundation, Inc. +Copyright 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -136,7 +136,7 @@ int main (void) { mpfr_t x; - mp_rnd_t r; + int r; mp_prec_t p; tests_start_mpfr (); @@ -151,21 +151,21 @@ main (void) for (r = 0; r < GMP_RND_MAX; r++) { mpfr_set_ui (x, 1, GMP_RNDN); - mpfr_cbrt (x, x, r); + mpfr_cbrt (x, x, (mp_rnd_t) r); if (mpfr_cmp_ui (x, 1)) { printf ("Error in mpfr_cbrt for x=1, rnd=%s\ngot ", - mpfr_print_rnd_mode (r)); + mpfr_print_rnd_mode ((mp_rnd_t) r)); mpfr_out_str (stdout, 2, 0, x, GMP_RNDN); printf ("\n"); exit (1); } mpfr_set_si (x, -1, GMP_RNDN); - mpfr_cbrt (x, x, r); + mpfr_cbrt (x, x, (mp_rnd_t) r); if (mpfr_cmp_si (x, -1)) { printf ("Error in mpfr_cbrt for x=-1, rnd=%s\ngot ", - mpfr_print_rnd_mode (r)); + mpfr_print_rnd_mode ((mp_rnd_t) r)); mpfr_out_str (stdout, 2, 0, x, GMP_RNDN); printf ("\n"); exit (1); @@ -183,7 +183,7 @@ main (void) { printf ("Error in mpfr_cbrt for " "x = 27.0 * 2^(%d), rnd=%s\ngot ", - 3*i, mpfr_print_rnd_mode (r)); + 3*i, mpfr_print_rnd_mode ((mp_rnd_t) r)); mpfr_out_str (stdout, 2, 0, x, GMP_RNDN); printf ("\ninstead of 3 * 2^(%d)\n", i); exit (1); diff --git a/tests/tcmp.c b/tests/tcmp.c index f40e9dbe1..725eec599 100644 --- a/tests/tcmp.c +++ b/tests/tcmp.c @@ -1,6 +1,6 @@ /* Test file for mpfr_cmp. -Copyright 1999, 2001, 2002, 2003 Free Software Foundation, Inc. +Copyright 1999, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -76,23 +76,24 @@ main (void) exit (1); } - mpfr_set_prec(xx, 53); mpfr_set_prec(yy, 200); - mpfr_set_ui(xx, 1, 0); - mpfr_set_ui(yy, 1, 0); - if (mpfr_cmp(xx, yy) != 0) + mpfr_set_prec (xx, 53); + mpfr_set_prec (yy, 200); + mpfr_set_ui (xx, 1, (mp_rnd_t) 0); + mpfr_set_ui (yy, 1, (mp_rnd_t) 0); + if (mpfr_cmp (xx, yy) != 0) { printf ("Error in mpfr_cmp: 1.0 != 1.0\n"); exit (1); } - mpfr_set_prec(yy, 31); - mpfr_set_str(xx, "1.0000000002", 10, 0); - mpfr_set_ui(yy, 1, 0); - if (!(mpfr_cmp(xx,yy)>0)) + mpfr_set_prec (yy, 31); + mpfr_set_str (xx, "1.0000000002", 10, (mp_rnd_t) 0); + mpfr_set_ui (yy, 1, (mp_rnd_t) 0); + if (!(mpfr_cmp (xx,yy)>0)) { printf ("Error in mpfr_cmp: not 1.0000000002 > 1.0\n"); exit (1); } - mpfr_set_prec(yy, 53); + mpfr_set_prec (yy, 53); /* bug found by Gerardo Ballabio */ mpfr_set_ui(xx, 0, GMP_RNDN); diff --git a/tests/tcmpabs.c b/tests/tcmpabs.c index a0a9a9e9c..54869dfa0 100644 --- a/tests/tcmpabs.c +++ b/tests/tcmpabs.c @@ -1,6 +1,6 @@ /* Test file for mpfr_cmpabs. -Copyright 2004 Free Software Foundation, Inc. +Copyright 2004, 2005 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -65,14 +65,14 @@ main (void) mpfr_set_prec(xx, 53); mpfr_set_prec(yy, 200); - mpfr_set_ui(xx, 1, 0); - mpfr_set_ui(yy, 1, 0); + mpfr_set_ui (xx, 1, (mp_rnd_t) 0); + mpfr_set_ui (yy, 1, (mp_rnd_t) 0); if (mpfr_cmpabs(xx, yy) != 0) ERROR ("Error in mpfr_cmpabs: 1.0 != 1.0\n"); - mpfr_set_prec(yy, 31); - mpfr_set_str(xx, "-1.0000000002", 10, 0); - mpfr_set_ui(yy, 1, 0); + mpfr_set_prec (yy, 31); + mpfr_set_str (xx, "-1.0000000002", 10, (mp_rnd_t) 0); + mpfr_set_ui (yy, 1, (mp_rnd_t) 0); if (!(mpfr_cmpabs(xx,yy)>0)) ERROR ("Error in mpfr_cmpabs: not 1.0000000002 > 1.0\n"); mpfr_set_prec(yy, 53); diff --git a/tests/tconst_euler.c b/tests/tconst_euler.c index c8354792b..d72786817 100644 --- a/tests/tconst_euler.c +++ b/tests/tconst_euler.c @@ -1,6 +1,6 @@ /* Test file for mpfr_const_euler. -Copyright 2001, 2004 Free Software Foundation. +Copyright 2001, 2002, 2003, 2004, 2005 Free Software Foundation. This file is part of the MPFR Library. @@ -29,7 +29,7 @@ main (int argc, char *argv[]) { mpfr_t gamma, y, z, t; unsigned int err, prec, yprec, p0 = 2, p1 = 200; - mp_rnd_t rnd; + int rnd; tests_start_mpfr (); @@ -68,16 +68,16 @@ main (int argc, char *argv[]) for (rnd = 0; rnd < GMP_RND_MAX; rnd++) { mpfr_set_prec (y, yprec); - mpfr_const_euler (y, rnd); + mpfr_const_euler (y, (mp_rnd_t) rnd); err = (rnd == GMP_RNDN) ? yprec + 1 : yprec; - if (mpfr_can_round (y, err, rnd, rnd, prec)) + if (mpfr_can_round (y, err, (mp_rnd_t) rnd, (mp_rnd_t) rnd, prec)) { - mpfr_set (t, y, rnd); - mpfr_const_euler (z, rnd); + mpfr_set (t, y, (mp_rnd_t) rnd); + mpfr_const_euler (z, (mp_rnd_t) rnd); if (mpfr_cmp (t, z)) { printf ("results differ for prec=%u rnd_mode=%s\n", prec, - mpfr_print_rnd_mode (rnd)); + mpfr_print_rnd_mode ((mp_rnd_t) rnd)); printf (" got "); mpfr_out_str (stdout, 2, prec, z, GMP_RNDN); puts (""); diff --git a/tests/tconst_log2.c b/tests/tconst_log2.c index 119f99a7a..722faa8d0 100644 --- a/tests/tconst_log2.c +++ b/tests/tconst_log2.c @@ -1,6 +1,6 @@ /* Test file for mpfr_const_log2. -Copyright 1999, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +Copyright 1999, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -43,7 +43,7 @@ check (mp_prec_t p0, mp_prec_t p1) mpfr_set_prec (x, p0); mpfr_set_prec (y, p0); { - rnd = RND_RAND (); + rnd = (mp_rnd_t) RND_RAND (); mpfr_const_log2 (x, rnd); mpfr_set (y, z, rnd); if (mpfr_cmp (x, y) && mpfr_can_round (z, mpfr_get_prec(z), GMP_RNDN, @@ -135,7 +135,7 @@ main (int argc, char *argv[]) tests_start_mpfr (); p = (argc>1) ? atoi(argv[1]) : 53; - rnd = (argc>2) ? atoi(argv[2]) : GMP_RNDZ; + rnd = (argc>2) ? (mp_rnd_t) atoi(argv[2]) : GMP_RNDZ; mpfr_init (x); diff --git a/tests/tconst_pi.c b/tests/tconst_pi.c index 9fc388136..f4a92da05 100644 --- a/tests/tconst_pi.c +++ b/tests/tconst_pi.c @@ -1,6 +1,6 @@ /* Test file for mpfr_const_pi. -Copyright 1999, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +Copyright 1999, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -55,7 +55,7 @@ main (int argc, char *argv[]) { mpfr_t x; int p; - unsigned char rnd; + mp_rnd_t rnd; tests_start_mpfr (); @@ -67,7 +67,7 @@ main (int argc, char *argv[]) p = a; } - rnd = (argc > 2) ? atoi(argv[2]) : GMP_RNDZ; + rnd = (argc > 2) ? (mp_rnd_t) atoi(argv[2]) : GMP_RNDZ; mpfr_init2 (x, p); mpfr_const_pi (x, rnd); diff --git a/tests/tcos.c b/tests/tcos.c index 5c02f6709..1500508ee 100644 --- a/tests/tcos.c +++ b/tests/tcos.c @@ -121,12 +121,12 @@ special_overflow (void) mpfr_init2 (y, 73); /* Check special case: An overflow in const_pi could occurs! */ - mpfr_set_emin (-125); - mpfr_set_emax (128); + set_emin (-125); + set_emax (128); mpfr_set_str_binary (x, "0.111101010110110011101101E6"); mpfr_cos (y, x, GMP_RNDZ); - mpfr_set_emin (MPFR_EMIN_MIN); - mpfr_set_emax (MPFR_EMAX_MAX); + set_emin (MPFR_EMIN_MIN); + set_emax (MPFR_EMAX_MAX); mpfr_clear (x); mpfr_clear (y); diff --git a/tests/tcosh.c b/tests/tcosh.c index d48a4ed68..74b138a7b 100644 --- a/tests/tcosh.c +++ b/tests/tcosh.c @@ -110,8 +110,8 @@ special_overflow (void) 3. cosh(x) exp overflow even with the largest range of exp */ mpfr_t x, y; - mpfr_set_emin (-125); - mpfr_set_emax (128); + set_emin (-125); + set_emax (128); mpfr_init2 (x, 24); mpfr_init2 (y, 24); @@ -134,8 +134,8 @@ special_overflow (void) exit (1); } - mpfr_set_emin (MPFR_EMIN_MIN); - mpfr_set_emax (MPFR_EMAX_MAX); + set_emin (MPFR_EMIN_MIN); + set_emax (MPFR_EMAX_MAX); mpfr_set_str_binary (x, "0.101100100000000000110100E1000000"); mpfr_cosh (y, x, GMP_RNDN); diff --git a/tests/tdiv.c b/tests/tdiv.c index 4e9457b56..717a47359 100644 --- a/tests/tdiv.c +++ b/tests/tdiv.c @@ -1,6 +1,6 @@ /* Test file for mpfr_div. -Copyright 1999, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +Copyright 1999, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -211,11 +211,11 @@ check_convergence (void) for (j = 0;j < GMP_RND_MAX; j++) { mpfr_set_ui (y, 1, GMP_RNDN); - mpfr_div (y, x, y, j); + mpfr_div (y, x, y, (mp_rnd_t) j); if (mpfr_cmp_ui (y, 1)) { printf ("mpfr_div failed for x=1.0, y=1.0, prec=%d rnd=%s\n", - i, mpfr_print_rnd_mode(j)); + i, mpfr_print_rnd_mode ((mp_rnd_t) j)); printf ("got "); mpfr_print_binary(y); puts (""); exit (1); } @@ -428,7 +428,7 @@ check_inexact (void) mpfr_set_prec (y, py); mpfr_set_prec (z, py + pu); { - rnd = RND_RAND (); + rnd = (mp_rnd_t) RND_RAND (); inexact = mpfr_div (y, x, u, rnd); if (mpfr_mul (z, y, u, rnd)) { @@ -544,17 +544,17 @@ check_nan (void) /* check overflow */ emax = mpfr_get_emax (); - mpfr_set_emax (1); + set_emax (1); mpfr_set_ui (a, 1, GMP_RNDZ); mpfr_set_ui (d, 1, GMP_RNDZ); mpfr_div_2exp (d, d, 1, GMP_RNDZ); mpfr_div (q, a, d, GMP_RNDU); /* 1 / 0.5 = 2 -> overflow */ MPFR_ASSERTN (mpfr_inf_p (q) && mpfr_sgn (q) > 0); - mpfr_set_emax (emax); + set_emax (emax); /* check underflow */ emin = mpfr_get_emin (); - mpfr_set_emin (-1); + set_emin (-1); mpfr_set_ui (a, 1, GMP_RNDZ); mpfr_div_2exp (a, a, 2, GMP_RNDZ); mpfr_set_ui (d, 2, GMP_RNDZ); @@ -562,7 +562,7 @@ check_nan (void) MPFR_ASSERTN (mpfr_cmp_ui (q, 0) == 0 && MPFR_IS_POS (q)); mpfr_div (q, a, d, GMP_RNDN); /* 0.5*2^(-2) -> underflow */ MPFR_ASSERTN (mpfr_cmp_ui (q, 0) == 0 && MPFR_IS_POS (q)); - mpfr_set_emin (emin); + set_emin (emin); mpfr_clear (a); mpfr_clear (d); diff --git a/tests/tdiv_ui.c b/tests/tdiv_ui.c index 6acd3e1db..68a3ae916 100644 --- a/tests/tdiv_ui.c +++ b/tests/tdiv_ui.c @@ -1,6 +1,6 @@ /* Test file for mpfr_div_ui. -Copyright 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation. +Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation. This file is part of the MPFR Library. @@ -140,7 +140,7 @@ check_inexact (void) mp_prec_t px, py; int inexact, cmp; unsigned long int u; - mp_rnd_t rnd; + int rnd; mpfr_init (x); mpfr_init (y); @@ -161,8 +161,8 @@ check_inexact (void) mpfr_set_prec (z, py + mp_bits_per_limb); for (rnd = 0; rnd < GMP_RND_MAX; rnd++) { - inexact = mpfr_div_ui (y, x, u, rnd); - if (mpfr_mul_ui (z, y, u, rnd)) + inexact = mpfr_div_ui (y, x, u, (mp_rnd_t) rnd); + if (mpfr_mul_ui (z, y, u, (mp_rnd_t) rnd)) { printf ("z <- y * u should be exact for u=%lu\n", u); printf ("y="); mpfr_print_binary (y); puts (""); @@ -175,7 +175,7 @@ check_inexact (void) ((inexact < 0) && (cmp >= 0))) { printf ("Wrong inexact flag for u=%lu, rnd=%s\n", u, - mpfr_print_rnd_mode(rnd)); + mpfr_print_rnd_mode ((mp_rnd_t) rnd)); printf ("x="); mpfr_print_binary (x); puts (""); printf ("y="); mpfr_print_binary (y); puts (""); exit (1); diff --git a/tests/teq.c b/tests/teq.c index f0b7afb62..42c5e6b8f 100644 --- a/tests/teq.c +++ b/tests/teq.c @@ -1,6 +1,6 @@ /* Test file for mpfr_eq. -Copyright 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -75,8 +75,8 @@ special (void) mpfr_init2 (y, 53); mpfr_init2 (z, 53); - mpfr_set_str (x, "1", 10, 0); - mpfr_set_str (y, "1e-10000", 10, 0); + mpfr_set_str (x, "1", 10, (mp_rnd_t) 0); + mpfr_set_str (y, "1e-10000", 10, (mp_rnd_t) 0); mpfr_add (z, x, y, GMP_RNDU); for (i = 1; i <= 52; i++) diff --git a/tests/tests.c b/tests/tests.c index 495410f18..ef5a5a1ae 100644 --- a/tests/tests.c +++ b/tests/tests.c @@ -1,6 +1,6 @@ /* Miscellaneous support for test programs. -Copyright 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +Copyright 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -27,6 +27,7 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> +#include <string.h> #include <float.h> #if TIME_WITH_SYS_TIME @@ -38,6 +39,10 @@ MA 02111-1307, USA. */ # include <time.h> #endif +#if HAVE_SYS_FPU_H +# include <sys/fpu.h> +#endif + #include "mpfr-test.h" static void tests_rand_start (void); @@ -61,7 +66,7 @@ tests_end_mpfr (void) tests_memory_end (); } -void +static void tests_rand_start (void) { gmp_randstate_ptr rands; @@ -105,7 +110,7 @@ tests_rand_start (void) } } -void +static void tests_rand_end (void) { RANDS_CLEAR (); @@ -116,7 +121,7 @@ void mpfr_test_init () { double c, d, eps; -#ifdef __mips +#if HAVE_FPC_CSR /* to get denormalized numbers on IRIX64 */ union fpc_csr exp; @@ -287,3 +292,42 @@ ld_trace (const char *name, long double ld) } printf ("] %.20Lg\n", ld); } + +/* Open a file in the src directory - can't use fopen directly */ +FILE *src_fopen (const char *filename, const char *mode) +{ + const char *srcdir = getenv ("srcdir"); + char *buffer; + FILE *f; + + if (srcdir == NULL) + return fopen (filename, mode); + buffer = (char*) malloc (strlen (filename) + strlen (srcdir) + 1); + if (buffer == NULL) + { + printf ("src_fopen: failed to alloc memory)\n"); + exit (1); + } + sprintf (buffer, "%s/%s", srcdir, filename); + f = fopen (buffer, mode); + free (buffer); + return f; +} + +void set_emin (mp_exp_t exponent) +{ + if (mpfr_set_emin (exponent)) + { + printf ("set_emin: setting emin to %ld failed\n", (long int) exponent); + exit (1); + } +} + +void set_emax (mp_exp_t exponent) +{ + if (mpfr_set_emax (exponent)) + { + printf ("set_emax: setting emax to %ld failed\n", (long int) exponent); + exit (1); + } +} diff --git a/tests/texceptions.c b/tests/texceptions.c index 0d99daaec..282c13d37 100644 --- a/tests/texceptions.c +++ b/tests/texceptions.c @@ -1,6 +1,6 @@ /* Test file for exceptions. -Copyright 2001, 2002, 2003, 2004 Free Software Foundation. +Copyright 2001, 2002, 2003, 2004, 2005 Free Software Foundation. This file is part of the MPFR Library. @@ -30,18 +30,19 @@ MA 02111-1307, USA. */ static void check_default_rnd (void) { - mp_rnd_t r, t; + int r; + mp_rnd_t t; for(r = 0 ; r < GMP_RND_MAX ; r++) { - mpfr_set_default_rounding_mode (r); + mpfr_set_default_rounding_mode ((mp_rnd_t) r); t = mpfr_get_default_rounding_mode(); - if (r !=t) + if ((mp_rnd_t) r != t) ERROR("ERROR in setting / getting default rounding mode (1)\n"); } - mpfr_set_default_rounding_mode(4); + mpfr_set_default_rounding_mode ((mp_rnd_t) 4); if (mpfr_get_default_rounding_mode() != GMP_RNDD) ERROR("ERROR in setting / getting default rounding mode (2)\n"); - mpfr_set_default_rounding_mode(-1); + mpfr_set_default_rounding_mode ((mp_rnd_t) -1); if (mpfr_get_default_rounding_mode() != GMP_RNDD) ERROR("ERROR in setting / getting default rounding mode (3)\n"); } @@ -82,8 +83,8 @@ mpfr_set_double_range (void) (We have to add one for mpfr since mantissa are between 1/2 and 1.) */ - mpfr_set_emin (-1021); - mpfr_set_emax (1024); + set_emin (-1021); + set_emax (1024); } static void @@ -137,7 +138,7 @@ test_set_underflow (void) mpfr_t x, zero, min; mpfr_ptr r[4]; int t[4] = { 1, -1, 1, -1 }; - mp_rnd_t i; + int i; int s; mpfr_inits (x, zero, min, (mpfr_ptr) 0); @@ -154,11 +155,11 @@ test_set_underflow (void) int inex; j = s < 0 && i > 1 ? 5 - i : i; - inex = mpfr_set_underflow (x, i, s); + inex = mpfr_set_underflow (x, (mp_rnd_t) i, s); if (mpfr_cmp (x, r[j]) || inex * t[j] <= 0) { printf ("Error in test_set_underflow, sign = %d," - " rnd_mode = %s\n", s, mpfr_print_rnd_mode (i)); + " rnd_mode = %s\n", s, mpfr_print_rnd_mode ((mp_rnd_t) i)); printf ("Got\n"); mpfr_out_str (stdout, 2, 0, x, GMP_RNDN); printf (", inex = %d\ninstead of\n", inex); @@ -180,7 +181,7 @@ test_set_overflow (void) mpfr_t x, inf, max; mpfr_ptr r[4]; int t[4] = { 1, -1, 1, -1 }; - mp_rnd_t i; + int i; int s; mpfr_inits2 (32, x, inf, max, (mpfr_ptr) 0); @@ -197,11 +198,11 @@ test_set_overflow (void) int inex; j = s < 0 && i > 1 ? 5 - i : i; - inex = mpfr_set_overflow (x, i, s); + inex = mpfr_set_overflow (x, (mp_rnd_t) i, s); if (mpfr_cmp (x, r[j]) || inex * t[j] <= 0) { printf ("Error in test_set_overflow, sign = %d," - " rnd_mode = %s\n", s, mpfr_print_rnd_mode (i)); + " rnd_mode = %s\n", s, mpfr_print_rnd_mode ((mp_rnd_t) i)); printf ("Got\n"); mpfr_out_str (stdout, 2, 0, x, GMP_RNDN); printf (", inex = %d\ninstead of\n", inex); @@ -249,7 +250,7 @@ main (int argc, char *argv[]) exit (1); } - mpfr_set_emax (1025); + set_emax (1025); mpfr_set_ui (x, 1, GMP_RNDN); mpfr_mul_2exp (x, x, 1024, GMP_RNDN); mpfr_set_double_range (); @@ -293,7 +294,7 @@ main (int argc, char *argv[]) exit (1); } - mpfr_set_emin (-1026); + set_emin (-1026); mpfr_set_ui (x, 1, GMP_RNDN); mpfr_div_2exp (x, x, 1025, GMP_RNDN); mpfr_set_double_range (); diff --git a/tests/texp.c b/tests/texp.c index d1bba9a51..3ff9acfae 100644 --- a/tests/texp.c +++ b/tests/texp.c @@ -1,6 +1,6 @@ /* Test file for mpfr_exp. -Copyright 1999, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +Copyright 1999, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -31,6 +31,8 @@ check3 (const char *op, mp_rnd_t rnd, const char *res) mpfr_t x, y; mpfr_inits2 (53, x, y, NULL); + /* y negative. If we forget to set the sign in mpfr_exp, we'll see it. */ + mpfr_set_si (y, -1, GMP_RNDN); mpfr_set_str1 (x, op); mpfr_exp (y, x, rnd); if (mpfr_cmp_str1 (y, res) ) @@ -142,7 +144,7 @@ compare_exp2_exp3 (int n) mpfr_set_prec (y, prec); mpfr_set_prec (z, prec); mpfr_random (x); - rnd = RND_RAND() ; + rnd = (mp_rnd_t) RND_RAND(); mpfr_exp_2 (y, x, rnd); mpfr_exp_3 (z, x, rnd); if (mpfr_cmp (y,z)) @@ -217,7 +219,7 @@ check_special () /* check overflow */ emax = mpfr_get_emax (); - mpfr_set_emax (10); + set_emax (10); mpfr_set_ui (x, 7, GMP_RNDN); mpfr_exp (y, x, GMP_RNDN); if (!mpfr_inf_p (y) || mpfr_sgn (y) < 0) @@ -225,11 +227,11 @@ check_special () printf ("Error for exp(7) for emax=10\n"); exit (1); } - mpfr_set_emax (emax); + set_emax (emax); /* check underflow */ emin = mpfr_get_emin (); - mpfr_set_emin (-10); + set_emin (-10); mpfr_set_si (x, -9, GMP_RNDN); mpfr_exp (y, x, GMP_RNDN); if (mpfr_cmp_ui (y, 0) || mpfr_sgn (y) < 0) @@ -239,7 +241,7 @@ check_special () printf ("Got "); mpfr_print_binary (y); puts (""); exit (1); } - mpfr_set_emin (emin); + set_emin (emin); /* check case EXP(x) < -precy */ mpfr_set_prec (y, 2); @@ -295,8 +297,8 @@ check_special () mpfr_exp_3 (y, x, GMP_RNDN); /* Check some little things about overflow detection */ - mpfr_set_emin (-125); - mpfr_set_emax (128); + set_emin (-125); + set_emax (128); mpfr_set_prec (x, 107); mpfr_set_prec (y, 107); mpfr_set_str_binary (x, "0.11110000000000000000000000000000000000000000000" @@ -312,8 +314,8 @@ check_special () exit (1); } - mpfr_set_emin (MPFR_EMIN_MIN); - mpfr_set_emax (MPFR_EMAX_MAX); + set_emin (MPFR_EMIN_MIN); + set_emax (MPFR_EMAX_MAX); /* Check for overflow producing a segfault with HUGE exponent */ mpfr_set_ui (x, 3, GMP_RNDN); @@ -385,6 +387,8 @@ main (int argc, char *argv[]) compare_exp2_exp3(500); check_worst_cases(); check3("0.0", GMP_RNDU, "1.0"); + check3("-1e-170", GMP_RNDU, "1.0"); + check3("-1e-170", GMP_RNDN, "1.0"); check3("-8.88024741073346941839e-17", GMP_RNDU, "1.0"); check3("8.70772839244701057915e-01", GMP_RNDN, "2.38875626491680437269"); check3("1.0", GMP_RNDN, "2.71828182845904509080"); diff --git a/tests/texp2.c b/tests/texp2.c index e304f85d6..771346efe 100644 --- a/tests/texp2.c +++ b/tests/texp2.c @@ -33,8 +33,8 @@ special_overflow (void) { mpfr_t x, y; - mpfr_set_emin (-125); - mpfr_set_emax (128); + set_emin (-125); + set_emax (128); mpfr_init2 (x, 24); mpfr_init2 (y, 24); @@ -50,8 +50,8 @@ special_overflow (void) mpfr_clear (y); mpfr_clear (x); - mpfr_set_emin (MPFR_EMIN_MIN); - mpfr_set_emax (MPFR_EMAX_MAX); + set_emin (MPFR_EMIN_MIN); + set_emax (MPFR_EMAX_MAX); } int @@ -102,7 +102,7 @@ main (int argc, char *argv[]) mpfr_set_prec (y, 10); /* save emin */ emin = mpfr_get_emin (); - mpfr_set_emin (-10); + set_emin (-10); mpfr_set_si (x, -12, GMP_RNDN); mpfr_exp2 (y, x, GMP_RNDN); if (mpfr_cmp_ui (y, 0) || mpfr_sgn (y) < 0) @@ -113,11 +113,11 @@ main (int argc, char *argv[]) exit (1); } /* restore emin */ - mpfr_set_emin (emin); + set_emin (emin); /* save emax */ emax = mpfr_get_emax (); - mpfr_set_emax (10); + set_emax (10); mpfr_set_ui (x, 11, GMP_RNDN); mpfr_exp2 (y, x, GMP_RNDN); if (!mpfr_inf_p (y) || mpfr_sgn (y) < 0) @@ -126,7 +126,7 @@ main (int argc, char *argv[]) exit (1); } /* restore emax */ - mpfr_set_emax (emax); + set_emax (emax); MPFR_SET_INF(x); diff --git a/tests/tfactorial.c b/tests/tfactorial.c index ce28a3de3..8a2834fd1 100644 --- a/tests/tfactorial.c +++ b/tests/tfactorial.c @@ -1,6 +1,6 @@ /* Test file for mpfr_factorial. -Copyright 2001, 2002, 2003, 2004 Free Software Foundation. +Copyright 2001, 2002, 2003, 2004, 2005 Free Software Foundation. This file is part of the MPFR Library. @@ -74,7 +74,7 @@ test_int (void) mpz_t f; mpfr_t x, y; mp_prec_t prec_f, p; - mp_rnd_t r; + int r; int inex1, inex2; mpz_init (f); @@ -92,19 +92,19 @@ test_int (void) mpfr_set_prec (y, p); for (r = 0; r < GMP_RND_MAX; r++) { - inex1 = mpfr_fac_ui (x, n, r); - inex2 = mpfr_set_z (y, f, r); + inex1 = mpfr_fac_ui (x, n, (mp_rnd_t) r); + inex2 = mpfr_set_z (y, f, (mp_rnd_t) r); if (mpfr_cmp (x, y)) { printf ("Error for n=%lu prec=%lu rnd=%s\n", - n, (unsigned long) p, mpfr_print_rnd_mode (r)); + n, (unsigned long) p, mpfr_print_rnd_mode ((mp_rnd_t) r)); exit (1); } if ((inex1 < 0 && inex2 >= 0) || (inex1 == 0 && inex2 != 0) || (inex1 > 0 && inex2 <= 0)) { printf ("Wrong inexact flag for n=%lu prec=%lu rnd=%s\n", - n, (unsigned long) p, mpfr_print_rnd_mode (r)); + n, (unsigned long) p, mpfr_print_rnd_mode ((mp_rnd_t) r)); exit (1); } } @@ -120,7 +120,7 @@ int main (int argc, char *argv[]) { unsigned int prec, err, yprec, n, k, zeros; - mp_rnd_t rnd; + int rnd; mpfr_t x, y, z, t; int inexact; @@ -154,12 +154,12 @@ main (int argc, char *argv[]) for (n = 0; n < 50; n++) for (rnd = 0; rnd < GMP_RND_MAX; rnd++) { - inexact = mpfr_fac_ui (y, n, rnd); + inexact = mpfr_fac_ui (y, n, (mp_rnd_t) rnd); err = (rnd == GMP_RNDN) ? yprec + 1 : yprec; - if (mpfr_can_round (y, err, rnd, rnd, prec)) + if (mpfr_can_round (y, err, (mp_rnd_t) rnd, (mp_rnd_t) rnd, prec)) { - mpfr_set (t, y, rnd); - inexact = mpfr_fac_ui (z, n, rnd); + mpfr_set (t, y, (mp_rnd_t) rnd); + inexact = mpfr_fac_ui (z, n, (mp_rnd_t) rnd); /* fact(n) ends with floor(n/2)+floor(n/4)+... zeros */ for (k=n/2, zeros=0; k; k >>= 1) zeros += k; @@ -187,7 +187,7 @@ main (int argc, char *argv[]) printf ("results differ for x="); mpfr_out_str (stdout, 2, prec, x, GMP_RNDN); printf (" prec=%u rnd_mode=%s\n", prec, - mpfr_print_rnd_mode (rnd)); + mpfr_print_rnd_mode ((mp_rnd_t) rnd)); printf (" got "); mpfr_out_str (stdout, 2, prec, z, GMP_RNDN); puts (""); diff --git a/tests/tfma.c b/tests/tfma.c index 8933476d2..8d5053224 100644 --- a/tests/tfma.c +++ b/tests/tfma.c @@ -1,6 +1,6 @@ /* Test file for mpfr_fma. -Copyright 2001, 2002, 2003, 2004 Free Software Foundation. +Copyright 2001, 2002, 2003, 2004, 2005 Free Software Foundation. Adapted from tarctan.c. This file is part of the MPFR Library. @@ -260,7 +260,7 @@ main (int argc, char *argv[]) if (randlimb () % 2) mpfr_neg (z, z, GMP_RNDN); - rnd = RND_RAND (); + rnd = (mp_rnd_t) RND_RAND (); mpfr_set_prec (slong, 2 * prec); if (mpfr_mul (slong, x, y, rnd)) { diff --git a/tests/tfrac.c b/tests/tfrac.c index 478e194f1..e6b229a5d 100644 --- a/tests/tfrac.c +++ b/tests/tfrac.c @@ -1,6 +1,6 @@ /* Test file for mpfr_frac. -Copyright 2002, 2003, 2004 Free Software Foundation. +Copyright 2002, 2003, 2004, 2005 Free Software Foundation. This file is part of the MPFR Library. @@ -113,16 +113,16 @@ check0 (mpfr_ptr ip, mpfr_ptr fp, mp_prec_t prec, mp_rnd_t rnd) static void check1 (mpfr_ptr ip, mpfr_ptr fp) { - mp_rnd_t rnd; + int rnd; for (rnd = 0; rnd < GMP_RND_MAX ; rnd++) { - check0 (ip, fp, PMAX, rnd); - check0 (ip, fp, 70, rnd); + check0 (ip, fp, PMAX, (mp_rnd_t) rnd); + check0 (ip, fp, 70, (mp_rnd_t) rnd); mpfr_neg (fp, fp, GMP_RNDN); mpfr_neg (ip, ip, GMP_RNDN); - check0 (ip, fp, PMAX, rnd); - check0 (ip, fp, 70, rnd); + check0 (ip, fp, PMAX, (mp_rnd_t) rnd); + check0 (ip, fp, 70, (mp_rnd_t) rnd); mpfr_neg (fp, fp, GMP_RNDN); mpfr_neg (ip, ip, GMP_RNDN); } diff --git a/tests/tgamma.c b/tests/tgamma.c index 5894bfd06..1d0af89de 100644 --- a/tests/tgamma.c +++ b/tests/tgamma.c @@ -171,8 +171,8 @@ special_overflow (void) { mpfr_t x, y; - mpfr_set_emin (-125); - mpfr_set_emax (128); + set_emin (-125); + set_emax (128); mpfr_init2 (x, 24); mpfr_init2 (y, 24); @@ -187,8 +187,8 @@ special_overflow (void) mpfr_clear (y); mpfr_clear (x); - mpfr_set_emin (MPFR_EMIN_MIN); - mpfr_set_emax (MPFR_EMAX_MAX); + set_emin (MPFR_EMIN_MIN); + set_emax (MPFR_EMAX_MAX); } int diff --git a/tests/tgeneric.c b/tests/tgeneric.c index b55cb8e1c..17cedd053 100644 --- a/tests/tgeneric.c +++ b/tests/tgeneric.c @@ -1,6 +1,6 @@ /* Generic test file for functions with one mpfr_t argument. -Copyright 2001, 2002, 2003 Free Software Foundation. +Copyright 2001, 2002, 2003, 2004, 2005 Free Software Foundation. This file is part of the MPFR Library. @@ -48,7 +48,7 @@ test_generic (mp_prec_t p0, mp_prec_t p1, unsigned int N) #else mpfr_random (x); #endif - rnd = RND_RAND (); + rnd = (mp_rnd_t) RND_RAND (); mpfr_set_prec (y, yprec); compare = TEST_FUNCTION (y, x, rnd); if (mpfr_can_round (y, yprec, rnd, rnd, prec)) diff --git a/tests/tget_d_2exp.c b/tests/tget_d_2exp.c index bb47abee4..a009ca174 100644 --- a/tests/tget_d_2exp.c +++ b/tests/tget_d_2exp.c @@ -1,6 +1,6 @@ /* Test mpfr_get_d_2exp. -Copyright 1999, 2000, 2001, 2002, 2003 Free Software Foundation. +Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation. This file is part of the MPFR Library. @@ -49,7 +49,7 @@ check_round (void) for (neg = 0; neg <= 1; neg++) { - got = mpfr_get_d_2exp (&got_exp, f, rnd_mode); + got = mpfr_get_d_2exp (&got_exp, f, (mp_rnd_t) rnd_mode); if (neg == 0 ? (got < 0.5 || got >= 1.0) diff --git a/tests/tget_sj.c b/tests/tget_sj.c index 77f3dde5c..a5591818b 100644 --- a/tests/tget_sj.c +++ b/tests/tget_sj.c @@ -1,6 +1,6 @@ /* Test file for mpfr_get_sj and mpfr_get_uj. -Copyright 2004 Free Software Foundation, Inc. +Copyright 2004, 2005 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -62,7 +62,7 @@ check_sj (intmax_t s, mpfr_ptr x) for (i = -1; i <= 1; i++) { - mpfr_rnd_t rnd; + int rnd; mpfr_set_si_2exp (y, i, -2, GMP_RNDN); mpfr_add (y, y, x, GMP_RNDN); @@ -79,12 +79,12 @@ check_sj (intmax_t s, mpfr_ptr x) if (rnd == GMP_RNDU && i > 0) continue; /* rint (y) == x == s */ - r = mpfr_get_sj (y, rnd); + r = mpfr_get_sj (y, (mp_rnd_t) rnd); if (r != s) { printf ("Error in check_sj for y = "); mpfr_out_str (stdout, 2, 0, y, GMP_RNDN); - printf (" in %s\n", mpfr_print_rnd_mode (rnd)); + printf (" in %s\n", mpfr_print_rnd_mode ((mp_rnd_t) rnd)); printf ("Got %jd instead of %jd.\n", r, s); exit (1); } @@ -104,7 +104,7 @@ check_uj (uintmax_t u, mpfr_ptr x) for (i = -1; i <= 1; i++) { - mpfr_rnd_t rnd; + int rnd; mpfr_set_si_2exp (y, i, -2, GMP_RNDN); mpfr_add (y, y, x, GMP_RNDN); @@ -119,12 +119,12 @@ check_uj (uintmax_t u, mpfr_ptr x) if (rnd == GMP_RNDU && i > 0) continue; /* rint (y) == x == u */ - r = mpfr_get_uj (y, rnd); + r = mpfr_get_uj (y, (mp_rnd_t) rnd); if (r != u) { printf ("Error in check_uj for y = "); mpfr_out_str (stdout, 2, 0, y, GMP_RNDN); - printf (" in %s\n", mpfr_print_rnd_mode (rnd)); + printf (" in %s\n", mpfr_print_rnd_mode ((mp_rnd_t) rnd)); printf ("Got %ju instead of %ju.\n", r, u); exit (1); } diff --git a/tests/tget_str.c b/tests/tget_str.c index e644bc4ea..a2d8d7de9 100644 --- a/tests/tget_str.c +++ b/tests/tget_str.c @@ -1,6 +1,6 @@ /* Test file for mpfr_get_str. -Copyright 1999, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +Copyright 1999, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -287,6 +287,7 @@ check_small (void) exit (1); } mpfr_free_str (s); + mpfr_set_str_binary (x, "10100100001011001000011001101101000110100110000010111E89"); s = mpfr_get_str (NULL, &e, 10, 7, x, GMP_RNDN); if (strcmp (s, "3575392") || e != 43) @@ -295,6 +296,7 @@ check_small (void) exit (1); } mpfr_free_str (s); + mpfr_set_str_binary (x, "11000011011110110010100110001010000001010011001011001E-73"); s = mpfr_get_str (NULL, &e, 10, 8, x, GMP_RNDN); if (strcmp (s, "72822386") || e != -6) @@ -303,6 +305,7 @@ check_small (void) exit (1); } mpfr_free_str (s); + mpfr_set_str_binary (x, "10101010001101000111001100001000100011100010010001010E78"); s = mpfr_get_str (NULL, &e, 10, 9, x, GMP_RNDN); if (strcmp (s, "180992873") || e != 40) @@ -311,6 +314,7 @@ check_small (void) exit (1); } mpfr_free_str (s); + mpfr_set_str_binary (x, "10110111001000100000001101111001100101101110011011101E91"); s = mpfr_get_str (NULL, &e, 10, 10, x, GMP_RNDN); if (strcmp (s, "1595312255") || e != 44) @@ -343,6 +347,7 @@ check_small (void) exit (1); } mpfr_free_str (s); + mpfr_set_str_binary (x, "10010011010110011100010010100101100011101000011111111E92"); s = mpfr_get_str (NULL, &e, 10, 14, x, GMP_RNDN); if (strcmp (s, "25672105101864") || e != 44) @@ -351,6 +356,7 @@ check_small (void) exit (1); } mpfr_free_str (s); + mpfr_set_str_binary (x, "100110111110110001000101110100100101101000011111001E87"); s = mpfr_get_str (NULL, &e, 10, 15, x, GMP_RNDN); if (strcmp (s, "212231308858721") || e != 42) @@ -359,6 +365,15 @@ check_small (void) exit (1); } mpfr_free_str (s); + mpfr_set_str_binary (x, "10111010110000111000101100101111001011011100101001111E-128"); + s = mpfr_get_str (NULL, &e, 10, 15, x, GMP_RNDN); + if (strcmp (s, "193109287087290") || e != -22) + { + printf ("Error in mpfr_get_str (22b): s=%s e=%d\n", s, (int) e); + exit (1); + } + mpfr_free_str (s); + mpfr_set_str_binary (x, "10001101101011010001111110000111010111010000110101010E80"); s = mpfr_get_str (NULL, &e, 10, 16, x, GMP_RNDN); if (strcmp (s, "6026241735727920") || e != 40) @@ -367,6 +382,7 @@ check_small (void) exit (1); } mpfr_free_str (s); + mpfr_set_str_binary (x, "100010001011101001110101000110011001001000110001001E-81"); s = mpfr_get_str (NULL, &e, 10, 17, x, GMP_RNDN); if (strcmp (s, "49741483709103481") || e != -9) @@ -391,6 +407,7 @@ check_small (void) exit (1); } mpfr_free_str (s); + mpfr_set_str_binary (x, "11111001010011100101000001111111110001001001110110001E-136"); s = mpfr_get_str (NULL, &e, 10, 9, x, GMP_RNDN); if (strcmp (s, "100693858") || e != -24) @@ -424,6 +441,324 @@ check_small (void) } mpfr_free_str (s); + /* 8116315218207718*2^(-293) ~ 0.5100000000000000000015*10^(-72) */ + mpfr_set_str_binary (x, "11100110101011011111011100101011101110110001111100110E-293"); + s = mpfr_get_str (NULL, &e, 10, 2, x, GMP_RNDU); + if (strcmp (s, "52") || e != -72) + { + printf ("Error in mpfr_get_str (31u): s=%s e=%d\n", s, (int) e); + exit (1); + } + mpfr_free_str (s); + s = mpfr_get_str (NULL, &e, 10, 2, x, GMP_RNDD); + if (strcmp (s, "51") || e != -72) + { + printf ("Error in mpfr_get_str (31d): s=%s e=%d\n", s, (int) e); + exit (1); + } + mpfr_free_str (s); + + /* 6712731423444934*2^536 ~ .151000000000000000000067*10^178 */ + mpfr_set_str_binary (x, "10111110110010011000110010011111101111000111111000110E536"); + s = mpfr_get_str (NULL, &e, 10, 3, x, GMP_RNDU); + if (strcmp (s, "152") || e != 178) + { + printf ("Error in mpfr_get_str (32u): s=%s e=%d\n", s, (int) e); + exit (1); + } + mpfr_free_str (s); + s = mpfr_get_str (NULL, &e, 10, 3, x, GMP_RNDD); + if (strcmp (s, "151") || e != 178) + { + printf ("Error in mpfr_get_str (32d): s=%s e=%d\n", s, (int) e); + exit (1); + } + mpfr_free_str (s); + + /* 3356365711722467*2^540 ~ .120800000000000000000054*10^179 */ + mpfr_set_str_binary (x, "1011111011001001100011001001111110111100011111100011E540"); + s = mpfr_get_str (NULL, &e, 10, 4, x, GMP_RNDU); + if (strcmp (s, "1209") || e != 179) + { + printf ("Error in mpfr_get_str (33u): s=%s e=%d\n", s, (int) e); + exit (1); + } + mpfr_free_str (s); + s = mpfr_get_str (NULL, &e, 10, 4, x, GMP_RNDD); + if (strcmp (s, "1208") || e != 179) + { + printf ("Error in mpfr_get_str (33d): s=%s e=%d\n", s, (int) e); + exit (1); + } + mpfr_free_str (s); + + /* 6475049196144587*2^100 ~ .8208099999999999999999988*10^46 */ + mpfr_set_str_binary (x, "10111000000010000010111011111001111010100011111001011E100"); + s = mpfr_get_str (NULL, &e, 10, 5, x, GMP_RNDU); + if (strcmp (s, "82081") || e != 46) + { + printf ("Error in mpfr_get_str (34u): s=%s e=%d\n", s, (int) e); + exit (1); + } + mpfr_free_str (s); + s = mpfr_get_str (NULL, &e, 10, 5, x, GMP_RNDD); + if (strcmp (s, "82080") || e != 46) + { + printf ("Error in mpfr_get_str (34d): s=%s e=%d\n", s, (int) e); + exit (1); + } + mpfr_free_str (s); + + /* 6722280709661868*2^364 ~ .25260100000000000000000012*10^126 */ + mpfr_set_str_binary (x, "10111111000011110000011110001110001111010010010101100E364"); + s = mpfr_get_str (NULL, &e, 10, 6, x, GMP_RNDU); + if (strcmp (s, "252602") || e != 126) + { + printf ("Error in mpfr_get_str (35u): s=%s e=%d\n", s, (int) e); + exit (1); + } + mpfr_free_str (s); + s = mpfr_get_str (NULL, &e, 10, 6, x, GMP_RNDD); + if (strcmp (s, "252601") || e != 126) + { + printf ("Error in mpfr_get_str (35d): s=%s e=%d\n", s, (int) e); + exit (1); + } + mpfr_free_str (s); + + /* 5381065484265332*2^(-455) ~ .578389299999999999999999982*10^(-121) */ + mpfr_set_str_binary (x, "10011000111100000110011110000101100111110011101110100E-455"); + s = mpfr_get_str (NULL, &e, 10, 7, x, GMP_RNDU); + if (strcmp (s, "5783893") || e != -121) + { + printf ("Error in mpfr_get_str (36u): s=%s e=%d\n", s, (int) e); + exit (1); + } + mpfr_free_str (s); + s = mpfr_get_str (NULL, &e, 10, 7, x, GMP_RNDD); + if (strcmp (s, "5783892") || e != -121) + { + printf ("Error in mpfr_get_str (36d): s=%s e=%d\n", s, (int) e); + exit (1); + } + mpfr_free_str (s); + + /* 8369123604277281*2^(-852) ~ .27869147000000000000000000056*10^(-240) */ + mpfr_set_str_binary (x, "11101101110111010110001101111100000111010100000100001E-852"); + s = mpfr_get_str (NULL, &e, 10, 8, x, GMP_RNDU); + if (strcmp (s, "27869148") || e != -240) + { + printf ("Error in mpfr_get_str (37u): s=%s e=%d\n", s, (int) e); + exit (1); + } + mpfr_free_str (s); + s = mpfr_get_str (NULL, &e, 10, 8, x, GMP_RNDD); + if (strcmp (s, "27869147") || e != -240) + { + printf ("Error in mpfr_get_str (37d): s=%s e=%d\n", s, (int) e); + exit (1); + } + mpfr_free_str (s); + + /* 7976538478610756*2^377 ~ .245540326999999999999999999982*10^130 */ + mpfr_set_str_binary (x, "11100010101101001111010010110100011100000100101000100E377"); + s = mpfr_get_str (NULL, &e, 10, 9, x, GMP_RNDU); + if (strcmp (s, "245540327") || e != 130) + { + printf ("Error in mpfr_get_str (38u): s=%s e=%d\n", s, (int) e); + exit (1); + } + mpfr_free_str (s); + s = mpfr_get_str (NULL, &e, 10, 9, x, GMP_RNDD); + if (strcmp (s, "245540326") || e != 130) + { + printf ("Error in mpfr_get_str (38d): s=%s e=%d\n", s, (int) e); + exit (1); + } + mpfr_free_str (s); + + /* 8942832835564782*2^(-382) ~ .9078555839000000000000000000038*10^(-99) */ + mpfr_set_str_binary (x, "11111110001010111010110000110011100110001010011101110E-382"); + s = mpfr_get_str (NULL, &e, 10, 10, x, GMP_RNDU); + if (strcmp (s, "9078555840") || e != -99) + { + printf ("Error in mpfr_get_str (39u): s=%s e=%d\n", s, (int) e); + exit (1); + } + mpfr_free_str (s); + s = mpfr_get_str (NULL, &e, 10, 10, x, GMP_RNDD); + if (strcmp (s, "9078555839") || e != -99) + { + printf ("Error in mpfr_get_str (39d): s=%s e=%d\n", s, (int) e); + exit (1); + } + mpfr_free_str (s); + + /* 4471416417782391*2^(-380) ~ .18157111678000000000000000000077*10^(-98) */ + mpfr_set_str_binary (x, "1111111000101011101011000011001110011000101001110111E-380"); + s = mpfr_get_str (NULL, &e, 10, 11, x, GMP_RNDU); + if (strcmp (s, "18157111679") || e != -98) + { + printf ("Error in mpfr_get_str (40u): s=%s e=%d\n", s, (int) e); + exit (1); + } + mpfr_free_str (s); + s = mpfr_get_str (NULL, &e, 10, 11, x, GMP_RNDD); + if (strcmp (s, "18157111678") || e != -98) + { + printf ("Error in mpfr_get_str (40d): s=%s e=%d\n", s, (int) e); + exit (1); + } + mpfr_free_str (s); + + /* 7225450889282194*2^711 ~ .778380362292999999999999999999971*10^230 */ + mpfr_set_str_binary (x, "11001101010111000001001100001100110010000001010010010E711"); + s = mpfr_get_str (NULL, &e, 10, 12, x, GMP_RNDU); + if (strcmp (s, "778380362293") || e != 230) + { + printf ("Error in mpfr_get_str (41u): s=%s e=%d\n", s, (int) e); + exit (1); + } + mpfr_free_str (s); + s = mpfr_get_str (NULL, &e, 10, 12, x, GMP_RNDD); + if (strcmp (s, "778380362292") || e != 230) + { + printf ("Error in mpfr_get_str (41d): s=%s e=%d\n", s, (int) e); + exit (1); + } + mpfr_free_str (s); + + /* 3612725444641097*2^713 ~ .1556760724585999999999999999999942*10^231 */ + mpfr_set_str_binary (x, "1100110101011100000100110000110011001000000101001001E713"); + s = mpfr_get_str (NULL, &e, 10, 13, x, GMP_RNDU); + if (strcmp (s, "1556760724586") || e != 231) + { + printf ("Error in mpfr_get_str (42u): s=%s e=%d\n", s, (int) e); + exit (1); + } + mpfr_free_str (s); + s = mpfr_get_str (NULL, &e, 10, 13, x, GMP_RNDD); + if (strcmp (s, "1556760724585") || e != 231) + { + printf ("Error in mpfr_get_str (42d): s=%s e=%d\n", s, (int) e); + exit (1); + } + mpfr_free_str (s); + + /* 6965949469487146*2^(-248) ~ .15400733123779000000000000000000016*10^(-58) */ + mpfr_set_str_binary (x, "11000101111110111111001111111101001101111000000101010E-248"); + s = mpfr_get_str (NULL, &e, 10, 14, x, GMP_RNDU); + if (strcmp (s, "15400733123780") || e != -58) + { + printf ("Error in mpfr_get_str (43u): s=%s e=%d\n", s, (int) e); + exit (1); + } + mpfr_free_str (s); + s = mpfr_get_str (NULL, &e, 10, 14, x, GMP_RNDD); + if (strcmp (s, "15400733123779") || e != -58) + { + printf ("Error in mpfr_get_str (43d): s=%s e=%d\n", s, (int) e); + exit (1); + } + mpfr_free_str (s); + + /* 3482974734743573*2^(-244) ~ .12320586499023200000000000000000013*10^(-57) */ + mpfr_set_str_binary (x, "1100010111111011111100111111110100110111100000010101E-244"); + s = mpfr_get_str (NULL, &e, 10, 15, x, GMP_RNDU); + if (strcmp (s, "123205864990233") || e != -57) + { + printf ("Error in mpfr_get_str (44u): s=%s e=%d\n", s, (int) e); + exit (1); + } + mpfr_free_str (s); + s = mpfr_get_str (NULL, &e, 10, 15, x, GMP_RNDD); + if (strcmp (s, "123205864990232") || e != -57) + { + printf ("Error in mpfr_get_str (44d): s=%s e=%d\n", s, (int) e); + exit (1); + } + mpfr_free_str (s); + + /* 7542952370752766*2^(-919) ~ .170206189963739699999999999999999974*10^(-260) */ + mpfr_set_str_binary (x, "11010110011000100011001110100100111011100110011111110E-919"); + s = mpfr_get_str (NULL, &e, 10, 16, x, GMP_RNDU); + if (strcmp (s, "1702061899637397") || e != -260) + { + printf ("Error in mpfr_get_str (45u): s=%s e=%d\n", s, (int) e); + exit (1); + } + mpfr_free_str (s); + s = mpfr_get_str (NULL, &e, 10, 16, x, GMP_RNDD); + if (strcmp (s, "1702061899637396") || e != -260) + { + printf ("Error in mpfr_get_str (45d): s=%s e=%d\n", s, (int) e); + exit (1); + } + mpfr_free_str (s); + + /* 5592117679628511*2^165 ~ .26153245263757307000000000000000000074*10^66 */ + mpfr_set_str_binary (x, "10011110111100000000001011011110101100010000011011111E165"); + s = mpfr_get_str (NULL, &e, 10, 17, x, GMP_RNDU); + if (strcmp (s, "26153245263757308") || e != 66) + { + printf ("Error in mpfr_get_str (46u): s=%s e=%d\n", s, (int) e); + exit (1); + } + mpfr_free_str (s); + s = mpfr_get_str (NULL, &e, 10, 17, x, GMP_RNDD); + if (strcmp (s, "26153245263757307") || e != 66) + { + printf ("Error in mpfr_get_str (46d): s=%s e=%d\n", s, (int) e); + exit (1); + } + mpfr_free_str (s); + + mpfr_set_str_binary (x, "11010010110111100001011010000110010000100001011011101E1223"); + s = mpfr_get_str (NULL, &e, 10, 17, x, GMP_RNDN); + if (strcmp (s, "10716284017294180") || e != 385) + { + printf ("Error in mpfr_get_str (47n): s=%s e=%d\n", s, (int) e); + exit (1); + } + mpfr_free_str (s); + s = mpfr_get_str (NULL, &e, 10, 18, x, GMP_RNDU); + if (strcmp (s, "107162840172941805") || e != 385) + { + printf ("Error in mpfr_get_str (47u): s=%s e=%d\n", s, (int) e); + exit (1); + } + mpfr_free_str (s); + s = mpfr_get_str (NULL, &e, 10, 18, x, GMP_RNDD); + if (strcmp (s, "107162840172941804") || e != 385) + { + printf ("Error in mpfr_get_str (47d): s=%s e=%d\n", s, (int) e); + exit (1); + } + mpfr_free_str (s); + + mpfr_set_str_binary (x, "11111101111011000001010100001101101000010010001111E122620"); + s = mpfr_get_str (NULL, &e, 10, 17, x, GMP_RNDN); + if (strcmp (s, "22183435284042374") || e != 36928) + { + printf ("Error in mpfr_get_str (48n): s=%s e=%ld\n", s, (long) e); + exit (1); + } + mpfr_free_str (s); + s = mpfr_get_str (NULL, &e, 10, 18, x, GMP_RNDU); + if (strcmp (s, "221834352840423736") || e != 36928) + { + printf ("Error in mpfr_get_str (48u): s=%s e=%ld\n", s, (long) e); + exit (1); + } + mpfr_free_str (s); + s = mpfr_get_str (NULL, &e, 10, 18, x, GMP_RNDD); + if (strcmp (s, "221834352840423735") || e != 36928) + { + printf ("Error in mpfr_get_str (48d): s=%s e=%ld\n", s, (long) e); + exit (1); + } + mpfr_free_str (s); + mpfr_set_prec (x, 45); mpfr_set_str_binary (x, "1E45"); s = mpfr_get_str (NULL, &e, 32, 9, x, GMP_RNDN); @@ -628,7 +963,7 @@ check_special (int b, mp_prec_t p) int i, j; char s[MAX_DIGITS + 2], s2[MAX_DIGITS + 2], c; mp_exp_t e; - mp_rnd_t r; + int r; size_t m; /* check for invalid base */ @@ -647,7 +982,7 @@ check_special (int b, mp_prec_t p) for (r = 0; r < GMP_RND_MAX; r++) for (m= (i<3)? 2 : i-1 ; (int) m <= i+1 ; m++) { - mpfr_get_str (s, &e, b, m, x, r); + mpfr_get_str (s, &e, b, m, x, (mp_rnd_t) r); /* s should be 1 followed by (m-1) zeros, and e should be i+1 */ if ((e != i+1) || strncmp (s, s2, m) != 0) { @@ -661,7 +996,7 @@ check_special (int b, mp_prec_t p) for (r = 0; r < GMP_RND_MAX; r++) if (i >= 2) { - mpfr_get_str (s, &e, b, i, x, r); + mpfr_get_str (s, &e, b, i, x, (mp_rnd_t) r); /* should be i times (b-1) */ c = (b <= 10) ? '0' + b - 1 : 'a' + (b - 11); for (j=0; (j < i) && (s[j] == c); j++); @@ -752,7 +1087,7 @@ main (int argc, char *argv[]) mpfr_set_exp (x, (e == -10) ? mpfr_get_emin () : ((e == 10) ? mpfr_get_emax () : e)); b = 2 + (randlimb () % 35); - r = RND_RAND(); + r = (mp_rnd_t) RND_RAND(); mpfr_get_str (s, &f, b, m, x, r); } mpfr_clear (x); diff --git a/tests/tgmpop.c b/tests/tgmpop.c index 8f939f224..857ede7c7 100644 --- a/tests/tgmpop.c +++ b/tests/tgmpop.c @@ -1,7 +1,7 @@ /* Test file for mpfr_add_[q,z], mpfr_sub_[q,z], mpfr_div_[q,z], mpfr_mul_[q,z] and mpfr_cmp_[q,z] -Copyright 2004 Free Software Foundation. +Copyright 2004, 2005 Free Software Foundation. This file is part of the MPFR Library. @@ -118,7 +118,7 @@ check_for_zero () mpq_t q; mpz_t z; mpfr_t x; - mp_rnd_t r; + int r; mpfr_sign_t i; mpfr_init (x); @@ -135,43 +135,43 @@ check_for_zero () i+=MPFR_SIGN_POS-MPFR_SIGN_NEG) { MPFR_SET_SIGN(x, i); - mpfr_add_z (x, x, z, r); + mpfr_add_z (x, x, z, (mp_rnd_t) r); if (!MPFR_IS_ZERO(x) || MPFR_SIGN(x)!=i) { printf("GMP Zero errors for add_z & rnd=%s & s=%d\n", - mpfr_print_rnd_mode(r), i); + mpfr_print_rnd_mode ((mp_rnd_t) r), i); mpfr_dump (x); exit (1); } - mpfr_sub_z (x, x, z, r); + mpfr_sub_z (x, x, z, (mp_rnd_t) r); if (!MPFR_IS_ZERO(x) || MPFR_SIGN(x)!=i) { printf("GMP Zero errors for sub_z & rnd=%s & s=%d\n", - mpfr_print_rnd_mode(r), i); + mpfr_print_rnd_mode ((mp_rnd_t) r), i); mpfr_dump (x); exit (1); } - mpfr_mul_z (x, x, z, r); + mpfr_mul_z (x, x, z, (mp_rnd_t) r); if (!MPFR_IS_ZERO(x) || MPFR_SIGN(x)!=i) { printf("GMP Zero errors for mul_z & rnd=%s & s=%d\n", - mpfr_print_rnd_mode(r), i); + mpfr_print_rnd_mode ((mp_rnd_t) r), i); mpfr_dump (x); exit (1); } - mpfr_add_q (x, x, q, r); + mpfr_add_q (x, x, q, (mp_rnd_t) r); if (!MPFR_IS_ZERO(x) || MPFR_SIGN(x)!=i) { printf("GMP Zero errors for add_q & rnd=%s & s=%d\n", - mpfr_print_rnd_mode(r), i); + mpfr_print_rnd_mode ((mp_rnd_t) r), i); mpfr_dump (x); exit (1); } - mpfr_sub_q (x, x, q, r); + mpfr_sub_q (x, x, q, (mp_rnd_t) r); if (!MPFR_IS_ZERO(x) || MPFR_SIGN(x)!=i) { printf("GMP Zero errors for sub_q & rnd=%s & s=%d\n", - mpfr_print_rnd_mode(r), i); + mpfr_print_rnd_mode ((mp_rnd_t) r), i); mpfr_dump (x); exit (1); } @@ -389,7 +389,7 @@ test_genericz (mp_prec_t p0, mp_prec_t p1, unsigned int N, { mpfr_urandomb (arg1, RANDS); mpz_urandomb (arg2, RANDS, 1024); - rnd = RND_RAND (); + rnd = (mp_rnd_t) RND_RAND (); mpfr_set_prec (dst_big, 2*prec); compare = func(dst_big, arg1, arg2, rnd); if (mpfr_can_round (dst_big, 2*prec, rnd, rnd, prec)) @@ -467,7 +467,7 @@ test_genericq (mp_prec_t p0, mp_prec_t p1, unsigned int N, mpfr_urandomb (arg1, RANDS); mpq_set_ui (arg2, randlimb (), randlimb() ); mpq_canonicalize (arg2); - rnd = RND_RAND (); + rnd = (mp_rnd_t) RND_RAND (); mpfr_set_prec (dst_big, prec+10); compare = func(dst_big, arg1, arg2, rnd); if (mpfr_can_round (dst_big, prec+10, rnd, rnd, prec)) diff --git a/tests/thypot.c b/tests/thypot.c index fdb7eefab..0fa4982f1 100644 --- a/tests/thypot.c +++ b/tests/thypot.c @@ -1,6 +1,6 @@ /* Test file for mpfr_hypot. -Copyright 2001, 2002, 2003, 2004 Free Software Foundation. +Copyright 2001, 2002, 2003, 2004, 2005 Free Software Foundation. Adapted from tarctan.c. This file is part of the MPFR Library. @@ -147,7 +147,7 @@ main (int argc, char *argv[]) mpfr_neg (x1, x1, GMP_RNDN); if (randlimb () % 2) mpfr_neg (x2, x2, GMP_RNDN); - rnd = RND_RAND (); + rnd = (mp_rnd_t) RND_RAND (); mpfr_set_prec (y, yprec); compare =TEST_FUNCTION (y, x1,x2, rnd); diff --git a/tests/tinp_str.c b/tests/tinp_str.c index 534fd61da..4370be102 100644 --- a/tests/tinp_str.c +++ b/tests/tinp_str.c @@ -30,13 +30,12 @@ main (int argc, char *argv[]) mpfr_t x; FILE *f; int i; - tests_start_mpfr (); mpfr_init (x); mpfr_set_prec (x, 15); - f = fopen ("inp_str.data", "r"); + f = src_fopen ("inp_str.data", "r"); if (f == NULL) { printf ("Error, can't open inp_str.data\n"); diff --git a/tests/tlog.c b/tests/tlog.c index 1ad90cf5f..d6c3efe49 100644 --- a/tests/tlog.c +++ b/tests/tlog.c @@ -1,6 +1,6 @@ /* Test file for mpfr_log. -Copyright 1999, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +Copyright 1999, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -159,14 +159,14 @@ special (void) mpfr_init2 (y, 53); /* Check special case: An overflow in const_pi could occurs! */ - mpfr_set_emin (-125); - mpfr_set_emax (128); + set_emin (-125); + set_emax (128); mpfr_set_prec (y, 24*2); mpfr_set_prec (x, 24); mpfr_set_str_binary (x, "0.111110101010101011110101E0"); mpfr_log (y, x, GMP_RNDN); - mpfr_set_emin (MPFR_EMIN_MIN); - mpfr_set_emax (MPFR_EMAX_MAX); + set_emin (MPFR_EMIN_MIN); + set_emax (MPFR_EMAX_MAX); mpfr_set_prec (y, 53); mpfr_set_prec (x, 53); @@ -204,7 +204,7 @@ main (int argc, char *argv[]) if (argc==4) { /* tlog x prec rnd */ - check3 (atof(argv[1]), atoi(argv[2]), atoi(argv[3])); + check3 (atof(argv[1]), atoi(argv[2]), (mp_rnd_t) atoi(argv[3])); goto done; } diff --git a/tests/tmul.c b/tests/tmul.c index e825effda..55502c594 100644 --- a/tests/tmul.c +++ b/tests/tmul.c @@ -1,6 +1,6 @@ /* Test file for mpfr_mul. -Copyright 1999, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +Copyright 1999, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -217,7 +217,7 @@ check_exact (void) { mpfr_random (a); mpfr_random (b); - rnd = RND_RAND (); + rnd = (mp_rnd_t) RND_RAND (); inexact = mpfr_mul (c, a, b, rnd); if (mpfr_mul (d, a, b, rnd)) /* should be always exact */ { @@ -300,17 +300,17 @@ check_max(void) /* check underflow */ emin = mpfr_get_emin (); - mpfr_set_emin (0); + set_emin (0); mpfr_set_str_binary (xx, "0.1E0"); mpfr_set_str_binary (yy, "0.1E0"); mpfr_mul (zz, xx, yy, GMP_RNDN); /* exact result is 0.1E-1, which should round to 0 */ MPFR_ASSERTN(mpfr_cmp_ui (zz, 0) == 0 && MPFR_IS_POS(zz)); - mpfr_set_emin (emin); + set_emin (emin); /* coverage test for mpfr_powerof2_raw */ emin = mpfr_get_emin (); - mpfr_set_emin (0); + set_emin (0); mpfr_set_prec (xx, mp_bits_per_limb + 1); mpfr_set_str_binary (xx, "0.1E0"); mpfr_nextabove (xx); @@ -318,7 +318,7 @@ check_max(void) mpfr_mul (zz, xx, yy, GMP_RNDN); /* exact result is just above 0.1E-1, which should round to minfloat */ MPFR_ASSERTN(mpfr_cmp (zz, yy) == 0); - mpfr_set_emin (emin); + set_emin (emin); mpfr_clear(xx); mpfr_clear(yy); diff --git a/tests/tmul_ui.c b/tests/tmul_ui.c index 09bfb3490..b0b040603 100644 --- a/tests/tmul_ui.c +++ b/tests/tmul_ui.c @@ -1,6 +1,6 @@ /* Test file for mpfr_mul_ui. -Copyright 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation. +Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation. This file is part of the MPFR Library. @@ -31,7 +31,7 @@ check_inexact (mp_prec_t p) unsigned long u; mp_prec_t q; int inexact, cmp; - mp_rnd_t rnd; + int rnd; mpfr_init2 (x, p); mpfr_init (y); @@ -48,7 +48,7 @@ check_inexact (mp_prec_t p) for (rnd = 0; rnd < GMP_RND_MAX; rnd++) { mpfr_set_prec (y, q); - inexact = mpfr_mul_ui (y, x, u, rnd); + inexact = mpfr_mul_ui (y, x, u, (mp_rnd_t) rnd); cmp = mpfr_cmp (y, z); if (((inexact == 0) && (cmp != 0)) || ((inexact < 0) && (cmp >= 0)) || @@ -56,7 +56,7 @@ check_inexact (mp_prec_t p) { printf ("Wrong inexact flag for p=%u, q=%u, rnd=%s\n", (unsigned int) p, (unsigned int) q, - mpfr_print_rnd_mode (rnd)); + mpfr_print_rnd_mode ((mp_rnd_t) rnd)); exit (1); } } @@ -140,11 +140,11 @@ main (int argc, char *argv[]) MPFR_ASSERTN(mpfr_cmp_ui (x, 0) == 0 && MPFR_IS_POS(x)); emax = mpfr_get_emax (); - mpfr_set_emax (0); + set_emax (0); mpfr_set_str_binary (x, "0.1E0"); mpfr_mul_ui (x, x, 2, GMP_RNDN); MPFR_ASSERTN(mpfr_inf_p (x) && MPFR_IS_POS(x)); - mpfr_set_emax (emax); + set_emax (emax); mpfr_set_str (x, /*1.0/3.0*/ "0.333333333333333333333333333333333", 10, GMP_RNDZ); diff --git a/tests/tout_str.c b/tests/tout_str.c index c9997ce9b..4cdaf6642 100644 --- a/tests/tout_str.c +++ b/tests/tout_str.c @@ -1,6 +1,6 @@ /* Test file for mpfr_out_str. -Copyright 1999, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +Copyright 1999, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -135,7 +135,12 @@ main (int argc, char *argv[]) /* with no argument: prints to /dev/null, tout_str N: prints N tests to stdout */ if (argc == 1) - fout = fopen ("/dev/null", "w"); + { + fout = fopen ("/dev/null", "w"); + /* If we failed to open this device, try with a dummy file */ + if (fout == NULL) + fout = fopen ("mpfrtest.txt", "w"); + } else { fout = stdout; @@ -183,7 +188,7 @@ main (int argc, char *argv[]) #endif r = RND_RAND (); p = 2 + randlimb () % 35; - check (d, r, p); + check (d, (mp_rnd_t) r, p); } fclose (fout); diff --git a/tests/toutimpl.c b/tests/toutimpl.c index 2fd4eacd6..c1e60382d 100644 --- a/tests/toutimpl.c +++ b/tests/toutimpl.c @@ -1,7 +1,7 @@ /* Test file for internal debugging-out functions: mpfr_dump, mpfr_print_binary, mpfr_print_rnd_mode. -Copyright 2004 Free Software Foundation, Inc. +Copyright 2004, 2005 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -65,7 +65,7 @@ int main() printf ("Error for printing GMP_RNDZ\n"); exit (1); } - if (mpfr_print_rnd_mode (-1) != NULL || + if (mpfr_print_rnd_mode ((mp_rnd_t) -1) != NULL || mpfr_print_rnd_mode (GMP_RND_MAX) != NULL) { printf ("Error for illegal rounding mode values.\n"); diff --git a/tests/tpow.c b/tests/tpow.c index c0017bf66..08d6f4b39 100644 --- a/tests/tpow.c +++ b/tests/tpow.c @@ -1,6 +1,6 @@ /* Test file for mpfr_pow, mpfr_pow_ui and mpfr_pow_si. -Copyright 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +Copyright 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -155,7 +155,7 @@ check_inexact (mp_prec_t p) unsigned long u; mp_prec_t q; int inexact, cmp; - mp_rnd_t rnd; + int rnd; mpfr_init2 (x, p); mpfr_init (y); @@ -169,15 +169,15 @@ check_inexact (mp_prec_t p) mpfr_set_prec (y, q); mpfr_set_prec (z, q + 10); mpfr_set_prec (t, q); - inexact = mpfr_pow_ui (y, x, u, rnd); - cmp = mpfr_pow_ui (z, x, u, rnd); - if (mpfr_can_round (z, q + 10, rnd, rnd, q)) + inexact = mpfr_pow_ui (y, x, u, (mp_rnd_t) rnd); + cmp = mpfr_pow_ui (z, x, u, (mp_rnd_t) rnd); + if (mpfr_can_round (z, q + 10, (mp_rnd_t) rnd, (mp_rnd_t) rnd, q)) { - cmp = mpfr_set (t, z, rnd) || cmp; + cmp = mpfr_set (t, z, (mp_rnd_t) rnd) || cmp; if (mpfr_cmp (y, t)) { printf ("results differ for u=%lu rnd=%s\n", - u, mpfr_print_rnd_mode(rnd)); + u, mpfr_print_rnd_mode ((mp_rnd_t) rnd)); printf ("x="); mpfr_print_binary (x); puts (""); printf ("y="); mpfr_print_binary (y); puts (""); printf ("t="); mpfr_print_binary (t); puts (""); @@ -189,7 +189,7 @@ check_inexact (mp_prec_t p) { printf ("Wrong inexact flag for p=%u, q=%u, rnd=%s\n", (unsigned int) p, (unsigned int) q, - mpfr_print_rnd_mode (rnd)); + mpfr_print_rnd_mode ((mp_rnd_t) rnd)); printf ("expected %d, got %d\n", cmp, inexact); printf ("u=%lu x=", u); mpfr_print_binary (x); puts (""); printf ("y="); mpfr_print_binary (y); puts (""); diff --git a/tests/tpow3.c b/tests/tpow3.c index 0626d51dc..0e87a6138 100644 --- a/tests/tpow3.c +++ b/tests/tpow3.c @@ -1,6 +1,6 @@ /* Test file for mpfr_pow. -Copyright 2001, 2002, 2003 Free Software Foundation. +Copyright 2001, 2002, 2003, 2005 Free Software Foundation. Adapted from tarctan.c. This file is part of the MPFR Library. @@ -65,7 +65,7 @@ main (int argc, char *argv[]) mpfr_random (s); if (randlimb () % 2) mpfr_neg (s, s, GMP_RNDN); - rnd = RND_RAND (); + rnd = (mp_rnd_t) RND_RAND (); mpfr_set_prec (y, yprec); compare = mpfr_pow (y, x, s, rnd); err = (rnd == GMP_RNDN) ? yprec + 1 : yprec; diff --git a/tests/trandom.c b/tests/trandom.c index e5d1ff967..f59bbae4b 100644 --- a/tests/trandom.c +++ b/tests/trandom.c @@ -188,7 +188,7 @@ test_urandomb (long nbtests, mp_prec_t prec, int verbose) /* coverage test */ emin = mpfr_get_emin (); - mpfr_set_emin (1); /* the generated number in [0,1[ is not in the exponent + set_emin (1); /* the generated number in [0,1[ is not in the exponent range, except if it is zero */ k = mpfr_urandomb (x, state); if (MPFR_IS_ZERO(x) == 0 && (k == 0 || mpfr_nan_p (x) == 0)) @@ -197,7 +197,7 @@ test_urandomb (long nbtests, mp_prec_t prec, int verbose) mpfr_dump (x); exit (1); } - mpfr_set_emin (emin); + set_emin (emin); mpfr_clear (x); gmp_randclear (state); diff --git a/tests/trint.c b/tests/trint.c index e2b66939d..35f8e332d 100644 --- a/tests/trint.c +++ b/tests/trint.c @@ -1,6 +1,6 @@ /* Test file for mpfr_rint, mpfr_trunc, mpfr_floor, mpfr_ceil, mpfr_round. -Copyright 2002, 2003, 2004 Free Software Foundation. +Copyright 2002, 2003, 2004, 2005 Free Software Foundation. This file is part of the MPFR Library. @@ -25,6 +25,10 @@ MA 02111-1307, USA. */ #include "mpfr-test.h" +#if __MPFR_STDC (199901L) +# include <math.h> +#endif + static void special (void) { @@ -64,13 +68,13 @@ special (void) /* another coverage test */ emax = mpfr_get_emax (); - mpfr_set_emax (1); + set_emax (1); mpfr_set_prec (x, 3); mpfr_set_str_binary (x, "1.11E0"); mpfr_set_prec (y, 2); mpfr_rint (y, x, GMP_RNDU); /* x rounds to 1.0E1=0.1E2 which overflows */ MPFR_ASSERTN(mpfr_inf_p (y) && mpfr_sgn (y) > 0); - mpfr_set_emax (emax); + set_emax (emax); /* yet another */ mpfr_set_prec (x, 97); @@ -130,6 +134,19 @@ special (void) exit (1); } + /* Bug found by Mark J Watkins */ + mpfr_set_prec (x, 84); + mpfr_set_str_binary (x, + "0.110011010010001000000111101101001111111100101110010000000000000" \ + "000000000000000000000E32"); + mpfr_round (x, x); + if (mpfr_cmp_str (x, "0.1100110100100010000001111011010100000000000000" \ + "00000000000000000000000000000000000000E32", 2, GMP_RNDN)) + { + printf ("Rounding error when dest=src\n"); + exit (1); + } + mpfr_clear (x); mpfr_clear (y); } @@ -205,7 +222,7 @@ main (int argc, char *argv[]) mpz_t z; mp_prec_t p; mpfr_t x, y, t, u, v; - mp_rnd_t r; + int r; int inexact, sign_t; tests_start_mpfr (); @@ -246,7 +263,7 @@ main (int argc, char *argv[]) for (trint = 0; trint < 3; trint++) { if (trint == 2) - inexact = mpfr_rint (y, x, r); + inexact = mpfr_rint (y, x, (mp_rnd_t) r); else if (r == GMP_RNDN) inexact = mpfr_round (y, x); else if (r == GMP_RNDZ) @@ -260,13 +277,14 @@ main (int argc, char *argv[]) mpfr_rint_floor (y, x, GMP_RNDD)); if (mpfr_sub (t, y, x, GMP_RNDN)) err ("subtraction 1 should be exact", - s, x, y, p, r, trint, inexact); + s, x, y, p, (mp_rnd_t) r, trint, inexact); sign_t = mpfr_cmp_ui (t, 0); if (trint != 0 && (((inexact == 0) && (sign_t != 0)) || ((inexact < 0) && (sign_t >= 0)) || ((inexact > 0) && (sign_t <= 0)))) - err ("wrong inexact flag", s, x, y, p, r, trint, inexact); + err ("wrong inexact flag", + s, x, y, p, (mp_rnd_t) r, trint, inexact); if (inexact == 0) continue; /* end of the test for exact results */ @@ -275,31 +293,33 @@ main (int argc, char *argv[]) ((r == GMP_RNDU || (r == GMP_RNDZ && MPFR_SIGN (x) < 0)) && inexact < 0)) err ("wrong rounding direction", - s, x, y, p, r, trint, inexact); + s, x, y, p, (mp_rnd_t) r, trint, inexact); if (inexact < 0) { mpfr_add_ui (v, y, 1, GMP_RNDU); if (mpfr_cmp (v, x) <= 0) err ("representable integer between x and its " - "rounded value", s, x, y, p, r, trint, inexact); + "rounded value", + s, x, y, p, (mp_rnd_t) r, trint, inexact); } else { mpfr_sub_ui (v, y, 1, GMP_RNDD); if (mpfr_cmp (v, x) >= 0) err ("representable integer between x and its " - "rounded value", s, x, y, p, r, trint, inexact); + "rounded value", + s, x, y, p, (mp_rnd_t) r, trint, inexact); } if (r == GMP_RNDN) { int cmp; if (mpfr_sub (u, v, x, GMP_RNDN)) err ("subtraction 2 should be exact", - s, x, y, p, r, trint, inexact); + s, x, y, p, (mp_rnd_t) r, trint, inexact); cmp = mpfr_cmp_abs (t, u); if (cmp > 0) err ("faithful rounding, but not the nearest integer", - s, x, y, p, r, trint, inexact); + s, x, y, p, (mp_rnd_t) r, trint, inexact); if (cmp < 0) continue; /* |t| = |u|: x is the middle of two consecutive @@ -311,7 +331,8 @@ main (int argc, char *argv[]) mpfr_div_2ui (y, y, 1, GMP_RNDZ); if (!mpfr_integer_p (y)) err ("halfway case for mpfr_rint, result isn't an" - " even integer", s, x, y, p, r, trint, inexact); + " even integer", + s, x, y, p, (mp_rnd_t) r, trint, inexact); /* If floor(x) and ceil(x) aren't both representable integers, the mantissa must be even. */ mpfr_sub (v, v, y, GMP_RNDN); @@ -322,7 +343,8 @@ main (int argc, char *argv[]) + 1, GMP_RNDN); if (!mpfr_integer_p (y)) err ("halfway case for mpfr_rint, mantissa isn't" - " even", s, x, y, p, r, trint, inexact); + " even", s, x, y, p, (mp_rnd_t) r, trint, + inexact); } } else @@ -331,7 +353,8 @@ main (int argc, char *argv[]) if ((MPFR_SIGN (x) > 0 && inexact < 0) || (MPFR_SIGN (x) < 0 && inexact > 0)) err ("halfway case for mpfr_round, bad rounding" - " direction", s, x, y, p, r, trint, inexact); + " direction", + s, x, y, p, (mp_rnd_t) r, trint, inexact); } } } diff --git a/tests/tround_prec.c b/tests/tround_prec.c index b7e07c0fa..8073e59b0 100644 --- a/tests/tround_prec.c +++ b/tests/tround_prec.c @@ -56,12 +56,12 @@ main (void) MPFR_ASSERTN(mpfr_cmp_ui (x, 0) == 0 && MPFR_IS_NEG(x)); emax = mpfr_get_emax (); - mpfr_set_emax (0); + set_emax (0); mpfr_set_prec (x, 3); mpfr_set_str_binary (x, "0.111"); mpfr_prec_round (x, 2, GMP_RNDN); MPFR_ASSERTN(mpfr_inf_p (x) && mpfr_sgn (x) > 0); - mpfr_set_emax (emax); + set_emax (emax); mpfr_set_prec (x, mp_bits_per_limb + 2); mpfr_set_ui (x, 1, GMP_RNDN); diff --git a/tests/tset.c b/tests/tset.c index 04411a3d1..e8c6aa408 100644 --- a/tests/tset.c +++ b/tests/tset.c @@ -1,6 +1,6 @@ /* Test file for mpfr_set. -Copyright 2001, 2002, 2003, 2004 Free Software Foundation. +Copyright 2001, 2002, 2003, 2004, 2005 Free Software Foundation. This file is part of the MPFR Library. @@ -46,7 +46,7 @@ main (void) { mp_prec_t p, q; mpfr_t x, y, z, u; - mp_rnd_t rnd; + int rnd; int inexact, cmp; mp_exp_t emax; @@ -80,13 +80,13 @@ main (void) MPFR_ASSERTN(mpfr_cmp_ui (y, 0) == 0 && MPFR_IS_NEG(y)); emax = mpfr_get_emax (); - mpfr_set_emax (0); + set_emax (0); mpfr_set_prec (x, 3); mpfr_set_str_binary (x, "0.111"); mpfr_set_prec (y, 2); mpfr_set (y, x, GMP_RNDU); MPFR_ASSERTN(mpfr_inf_p (y) && mpfr_sgn (y) > 0); - mpfr_set_emax (emax); + set_emax (emax); mpfr_set_prec (y, 11); mpfr_set_str_binary (y, "0.11111111100E-8"); @@ -110,7 +110,7 @@ main (void) mpfr_set_prec (y, q); for (rnd = 0; rnd < GMP_RND_MAX; rnd++) { - inexact = mpfr_set (y, x, rnd); + inexact = mpfr_set (y, x, (mp_rnd_t) rnd); cmp = mpfr_cmp (y, x); if (((inexact == 0) && (cmp != 0)) || ((inexact > 0) && (cmp <= 0)) || diff --git a/tests/tset_d.c b/tests/tset_d.c index 0f096e30a..964a95036 100644 --- a/tests/tset_d.c +++ b/tests/tset_d.c @@ -1,6 +1,6 @@ /* Test file for mpfr_set_d and mpfr_get_d. -Copyright 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -108,16 +108,17 @@ main (int argc, char *argv[]) exit (1); } - mpfr_init2(z, 32); - mpfr_set_d(z, 1.0, 0); + mpfr_init2 (z, 32); + mpfr_set_d (z, 1.0, (mp_rnd_t) 0); if (mpfr_cmp_ui (z, 1)) { mpfr_print_binary (z); puts (""); printf ("Error: 1.0 != 1.0\n"); exit (1); } - mpfr_set_prec(x, 53); mpfr_init2(y, 53); - mpfr_set_d(x, d=-1.08007920352320089721e+150, 0); + mpfr_set_prec (x, 53); + mpfr_init2 (y, 53); + mpfr_set_d (x, d=-1.08007920352320089721e+150, (mp_rnd_t) 0); if (mpfr_get_d1 (x) != d) { mpfr_print_binary (x); puts (""); @@ -126,9 +127,9 @@ main (int argc, char *argv[]) exit (1); } - mpfr_set_d(x, 8.06294740693074521573e-310, 0); + mpfr_set_d (x, 8.06294740693074521573e-310, (mp_rnd_t) 0); d = -6.72658901114033715233e-165; - mpfr_set_d(x, d, 0); + mpfr_set_d (x, d, (mp_rnd_t) 0); if (d != mpfr_get_d1 (x)) { mpfr_print_binary (x); @@ -149,7 +150,7 @@ main (int argc, char *argv[]) #else while (ABS(d) < DBL_MIN); #endif - mpfr_set_d (x, d, 0); + mpfr_set_d (x, d, (mp_rnd_t) 0); dd = mpfr_get_d1 (x); if (d != dd && !(Isnan(d) && Isnan(dd))) { diff --git a/tests/tset_exp.c b/tests/tset_exp.c index 27381345a..9e29206f2 100644 --- a/tests/tset_exp.c +++ b/tests/tset_exp.c @@ -38,11 +38,11 @@ main (int argc, char *argv[]) ret = mpfr_set_exp (x, 2); MPFR_ASSERTN(ret == 0 && mpfr_cmp_ui (x, 2) == 0); - mpfr_set_emin (-1); + set_emin (-1); ret = mpfr_set_exp (x, -1); MPFR_ASSERTN(ret == 0 && mpfr_cmp_ui_2exp (x, 1, -2) == 0); - mpfr_set_emax (1); + set_emax (1); ret = mpfr_set_exp (x, 1); MPFR_ASSERTN(ret == 0 && mpfr_cmp_ui (x, 1) == 0); diff --git a/tests/tset_f.c b/tests/tset_f.c index a92a47003..32f266cad 100644 --- a/tests/tset_f.c +++ b/tests/tset_f.c @@ -1,6 +1,6 @@ /* Test file for mpfr_set_f. -Copyright 1999, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +Copyright 1999, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -47,7 +47,7 @@ main (void) mpfr_set_f (x, y, GMP_RNDN); mpf_random2 (y, 10, 0); - mpfr_set_f (x, y, RND_RAND() ); + mpfr_set_f (x, y, (mp_rnd_t) RND_RAND()); /* bug found by Jean-Pierre Merlet */ mpfr_set_prec (x, 256); @@ -93,25 +93,25 @@ main (void) mpf_set_prec (z, pr); mpf_random2 (z, z->_mp_prec, 0); mpfr_set_prec (x, pr); - mpfr_set_f (x, z, 0); + mpfr_set_f (x, z, (mp_rnd_t) 0); } /* Check for +0 */ mpfr_set_prec (x, 53); mpf_set_prec (y, 53); mpf_set_ui (y, 0); - for(r = 0 ; r < GMP_RND_MAX ; r++) + for (r = 0 ; r < GMP_RND_MAX ; r++) { int i; for (i = -1; i <= 1; i++) { if (i) mpfr_set_si (x, i, GMP_RNDN); - inexact = mpfr_set_f (x, y, r); + inexact = mpfr_set_f (x, y, (mp_rnd_t) r); if (!MPFR_IS_ZERO(x) || !MPFR_IS_POS(x) || inexact) { printf ("mpfr_set_f(x,0) failed for %s, i = %d\n", - mpfr_print_rnd_mode (r), i); + mpfr_print_rnd_mode ((mp_rnd_t) r), i); exit (1); } } diff --git a/tests/tset_ld.c b/tests/tset_ld.c index dbf806b0b..92a5d810c 100644 --- a/tests/tset_ld.c +++ b/tests/tset_ld.c @@ -1,6 +1,6 @@ /* Test file for mpfr_set_ld and mpfr_get_ld. -Copyright 2002, 2003, 2004 Free Software Foundation, Inc. +Copyright 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -57,13 +57,13 @@ Isnan_ld (long double d) static void check_set_get (long double d, mpfr_t x) { - mp_rnd_t r; + int r; long double e; int inex; for (r = 0; r < GMP_RND_MAX; r++) { - inex = mpfr_set_ld (x, d, r); + inex = mpfr_set_ld (x, d, (mp_rnd_t) r); if (inex != 0) { printf ("Error: mpfr_set_ld should be exact\n"); @@ -72,7 +72,7 @@ check_set_get (long double d, mpfr_t x) mpfr_dump (x); exit (1); } - e = mpfr_get_ld (x, r); + e = mpfr_get_ld (x, (mp_rnd_t) r); if (e != d && !(Isnan_ld(e) && Isnan_ld(d))) { printf ("Error: mpfr_get_ld o mpfr_set_ld <> Id\n"); @@ -172,14 +172,14 @@ main (int argc, char *argv[]) /* check with reduced emax to exercise overflow */ emax = mpfr_get_emax (); mpfr_set_prec (x, 2); - mpfr_set_emax (1); + set_emax (1); mpfr_set_ld (x, (long double) 2.0, GMP_RNDN); MPFR_ASSERTN(mpfr_inf_p (x) && mpfr_sgn (x) > 0); for (d = (long double) 2.0, i = 0; i < 13; i++, d *= d); /* now d = 2^8192 */ mpfr_set_ld (x, d, GMP_RNDN); MPFR_ASSERTN(mpfr_inf_p (x) && mpfr_sgn (x) > 0); - mpfr_set_emax (emax); + set_emax (emax); mpfr_clear (x); diff --git a/tests/tset_q.c b/tests/tset_q.c index 6dc01bb77..70d74f3af 100644 --- a/tests/tset_q.c +++ b/tests/tset_q.c @@ -1,6 +1,6 @@ /* Test file for mpfr_set_q. -Copyright 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +Copyright 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -75,24 +75,24 @@ static void check0(void) mpq_t y; mpfr_t x; int inexact; - mp_rnd_t r; + int r; /* Check for +0 */ - mpfr_init(x); - mpq_init(y); - mpq_set_si(y, 0, 1); - for(r = 0 ; r < GMP_RND_MAX ; r++) + mpfr_init (x); + mpq_init (y); + mpq_set_si (y, 0, 1); + for (r = 0; r < GMP_RND_MAX; r++) { - inexact = mpfr_set_q(x, y, r); + inexact = mpfr_set_q(x, y, (mp_rnd_t) r); if (!MPFR_IS_ZERO(x) || !MPFR_IS_POS(x) || inexact) { printf("mpfr_set_q(x,0) failed for %s\n", - mpfr_print_rnd_mode(r)); + mpfr_print_rnd_mode ((mp_rnd_t) r)); exit(1); } } - mpfr_clear(x); - mpq_clear(y); + mpfr_clear (x); + mpq_clear (y); } int diff --git a/tests/tset_si.c b/tests/tset_si.c index 9f4771283..e08366ce0 100644 --- a/tests/tset_si.c +++ b/tests/tset_si.c @@ -1,6 +1,6 @@ /* Test file for mpfr_set_si and mpfr_set_ui. -Copyright 1999, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +Copyright 1999, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -72,7 +72,7 @@ main (int argc, char *argv[]) long k, z, d, N; unsigned long zl, dl; int inex; - mp_rnd_t r; + int r; mp_exp_t emax; tests_start_mpfr (); @@ -167,40 +167,40 @@ main (int argc, char *argv[]) exit (1); } - for(r = 0 ; r < GMP_RND_MAX ; r++) + for (r = 0 ; r < GMP_RND_MAX ; r++) { - mpfr_set_si (x, -1, r); - mpfr_set_ui (x, 0, r); + mpfr_set_si (x, -1, (mp_rnd_t) r); + mpfr_set_ui (x, 0, (mp_rnd_t) r); if (MPFR_IS_NEG (x) ) { printf ("mpfr_set_ui (x, 0) gives -0 for %s\n", - mpfr_print_rnd_mode(r)); + mpfr_print_rnd_mode ((mp_rnd_t) r)); exit (1); } - mpfr_set_si (x, -1, r); - mpfr_set_si (x, 0, r); - if (MPFR_IS_NEG (x) ) + mpfr_set_si (x, -1, (mp_rnd_t) r); + mpfr_set_si (x, 0, (mp_rnd_t) r); + if (MPFR_IS_NEG (x)) { printf ("mpfr_set_si (x, 0) gives -0 for %s\n", - mpfr_print_rnd_mode(r) ); + mpfr_print_rnd_mode ((mp_rnd_t) r)); exit (1); } } /* check potential bug in case mp_limb_t is unsigned */ emax = mpfr_get_emax (); - mpfr_set_emax (0); + set_emax (0); mpfr_set_si (x, -1, GMP_RNDN); if (mpfr_sgn (x) >= 0) { printf ("mpfr_set_si (x, -1) fails\n"); exit (1); } - mpfr_set_emax (emax); + set_emax (emax); emax = mpfr_get_emax (); - mpfr_set_emax (5); + set_emax (5); mpfr_set_prec (x, 2); mpfr_set_si (x, -31, GMP_RNDN); if (mpfr_sgn (x) >= 0) @@ -208,7 +208,7 @@ main (int argc, char *argv[]) printf ("mpfr_set_si (x, -31) fails\n"); exit (1); } - mpfr_set_emax (emax); + set_emax (emax); /* test for get_ui */ mpfr_set_ui (x, 0, GMP_RNDN); @@ -244,13 +244,13 @@ main (int argc, char *argv[]) mpfr_set_ui (x, 7, GMP_RNDU); MPFR_ASSERTN(mpfr_cmp_ui (x, 8) == 0); emax = mpfr_get_emax (); - mpfr_set_emax (3); + set_emax (3); mpfr_set_ui (x, 7, GMP_RNDU); MPFR_ASSERTN(mpfr_inf_p (x) && mpfr_sgn (x) > 0); - mpfr_set_emax (1); + set_emax (1); MPFR_ASSERTN( mpfr_set_ui (x, 7, GMP_RNDU) ); MPFR_ASSERTN(mpfr_inf_p (x) && mpfr_sgn (x) > 0); - mpfr_set_emax (emax); + set_emax (emax); /* Test for ERANGE flag + correct behaviour if overflow */ mpfr_set_prec (x, 256); diff --git a/tests/tset_str.c b/tests/tset_str.c index 52beb6982..7867ca68b 100644 --- a/tests/tset_str.c +++ b/tests/tset_str.c @@ -1,6 +1,6 @@ /* Test file for mpfr_set_str. -Copyright 1999, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +Copyright 1999, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -29,6 +29,21 @@ MA 02111-1307, USA. */ #define N 30000 +#define CHECK53(y, s, r, x, t, n) \ + mpfr_set_str (y, s, 10, r); \ + mpfr_set_str_binary (x, t); \ + if (mpfr_cmp (x, y)) \ + { \ + printf ("Error in mpfr_set_str (%u):\n", n); \ + mpfr_print_binary (x); \ + puts (""); \ + mpfr_print_binary (y); \ + puts (""); \ + mpfr_clear (x); \ + mpfr_clear (y); \ + exit (1); \ + } + static void check_underflow (void) { @@ -40,9 +55,9 @@ check_underflow (void) /* Check underflow */ emin = mpfr_get_emin (); - mpfr_set_emin (-20); + set_emin (-20); res = mpfr_set_str (a, "0.00000000001", 10, GMP_RNDZ); - if (!MPFR_IS_ZERO (a) || res == 0) + if (!MPFR_IS_ZERO (a)) { printf("ERROR for mpfr_set_str (a, \"0.00000000001\", 10, GMP_RNDN)\n" " with emin=-20\n" @@ -50,18 +65,18 @@ check_underflow (void) mpfr_dump (a); exit (1); } - mpfr_set_emin (emin); + set_emin (emin); /* check overflow */ emax = mpfr_get_emax (); - mpfr_set_emax (1073741823); /* 2^30-1 */ + set_emax (1073741823); /* 2^30-1 */ mpfr_set_str (a, "2E1000000000", 10, GMP_RNDN); if (!mpfr_inf_p (a) || mpfr_sgn (a) < 0) { printf("ERROR for mpfr_set_str (a, \"2E1000000000\", 10, GMP_RNDN);\n"); exit (1); } - mpfr_set_emax (emax); + set_emax (emax); mpfr_clear (a); } @@ -96,10 +111,9 @@ main (int argc, char *argv[]) bd = randlimb () & 8; - str2 = str = (*__gmp_allocate_func) (nc * sizeof(char)); + str2 = str = (char*) (*__gmp_allocate_func) (nc * sizeof(char)); if (bd) - { for(k = 1; k <= bd; k++) *(str2++) = (randlimb () & 1) + '0'; @@ -197,13 +211,13 @@ main (int argc, char *argv[]) baseprec = prec; else baseprec = 1 + (prec - 2 + logbase) / logbase; - str = mpfr_get_str (NULL, &e, base, baseprec, x, k); - mpfr_set_str (y, str, base, k); + str = mpfr_get_str (NULL, &e, base, baseprec, x, (mp_rnd_t) k); + mpfr_set_str (y, str, base, (mp_rnd_t) k); MPFR_EXP(y) += logbase * (e - strlen (str)); if (mpfr_cmp (x, y)) { printf ("mpfr_set_str o mpfr_get_str <> id for rnd_mode=%s\n", - mpfr_print_rnd_mode (k)); + mpfr_print_rnd_mode ((mp_rnd_t) k)); printf ("x="); mpfr_print_binary (x); puts (""); @@ -220,13 +234,14 @@ main (int argc, char *argv[]) for (i = 2; i <= 36; i++) { - if (mpfr_set_str (x, "@NaN@garbage", i, GMP_RNDN) != 0 || + if (mpfr_set_str (x, "@NaN@(garbage)", i, GMP_RNDN) != 0 || !mpfr_nan_p(x)) { - printf ("mpfr_set_str failed on @NaN@garbage\n"); + printf ("mpfr_set_str failed on @NaN@(garbage)\n"); exit (1); } + /* if (mpfr_set_str (x, "@Inf@garbage", i, GMP_RNDN) != 0 || !mpfr_inf_p(x) || MPFR_SIGN(x) < 0) { @@ -247,6 +262,7 @@ main (int argc, char *argv[]) printf ("mpfr_set_str failed on +@Inf@garbage\n"); exit (1); } + */ if (i > 16) continue; @@ -406,6 +422,311 @@ main (int argc, char *argv[]) exit (1); } + /* worst cases for rounding to nearest in double precision */ + mpfr_set_prec (x, 53); + mpfr_set_prec (y, 53); + + mpfr_set_str (y, "5e125", 10, GMP_RNDN); + mpfr_set_str_binary (x, "0.10111101000101110110011000100000101001010000000111111E418"); + if (mpfr_cmp (x, y)) + { + printf ("Error in mpfr_set_str (8):\n"); + mpfr_print_binary (x); + puts (""); + mpfr_print_binary (y); + puts (""); + mpfr_clear (x); + mpfr_clear (y); + exit (1); + } + + mpfr_set_str (y, "69e267", 10, GMP_RNDN); + mpfr_set_str_binary (x, "0.10000101101111100101101100000110010011001010011011010E894"); + if (mpfr_cmp (x, y)) + { + printf ("Error in mpfr_set_str (9):\n"); + mpfr_print_binary (x); + puts (""); + mpfr_print_binary (y); + puts (""); + mpfr_clear (x); + mpfr_clear (y); + exit (1); + } + + mpfr_set_str (y, "623e100", 10, GMP_RNDN); + mpfr_set_str_binary (x, "0.10110010000001010011000101111001110101000001111011111E342"); + if (mpfr_cmp (x, y)) + { + printf ("Error in mpfr_set_str (10):\n"); + mpfr_print_binary (x); + puts (""); + mpfr_print_binary (y); + puts (""); + mpfr_clear (x); + mpfr_clear (y); + exit (1); + } + + mpfr_set_str (y, "3571e263", 10, GMP_RNDN); + mpfr_set_str_binary (x, "0.10110001001100100010011000110000111010100000110101010E886"); + if (mpfr_cmp (x, y)) + { + printf ("Error in mpfr_set_str (11):\n"); + mpfr_print_binary (x); + puts (""); + mpfr_print_binary (y); + puts (""); + mpfr_clear (x); + mpfr_clear (y); + exit (1); + } + + mpfr_set_str (y, "75569e-254", 10, GMP_RNDN); + mpfr_set_str_binary (x, "0.10101101001000110001011011001000111000110101010110011E-827"); + if (mpfr_cmp (x, y)) + { + printf ("Error in mpfr_set_str (12):\n"); + mpfr_print_binary (x); + puts (""); + mpfr_print_binary (y); + puts (""); + mpfr_clear (x); + mpfr_clear (y); + exit (1); + } + + mpfr_set_str (y, "920657e-23", 10, GMP_RNDN); + mpfr_set_str_binary (x, "0.10101001110101001100110000101110110111101111001101100E-56"); + if (mpfr_cmp (x, y)) + { + printf ("Error in mpfr_set_str (13):\n"); + mpfr_print_binary (x); + puts (""); + mpfr_print_binary (y); + puts (""); + mpfr_clear (x); + mpfr_clear (y); + exit (1); + } + + mpfr_set_str (y, "9210917e80", 10, GMP_RNDN); + mpfr_set_str_binary (x, "0.11101101000100011001000110100011111100110000000110010E289"); + if (mpfr_cmp (x, y)) + { + printf ("Error in mpfr_set_str (14):\n"); + mpfr_print_binary (x); + puts (""); + mpfr_print_binary (y); + puts (""); + mpfr_clear (x); + mpfr_clear (y); + exit (1); + } + + mpfr_set_str (y, "87575437e-309", 10, GMP_RNDN); + mpfr_set_str_binary (x, "0.11110000001110011001000000110000000100000010101101100E-1000"); + if (mpfr_cmp (x, y)) + { + printf ("Error in mpfr_set_str (15):\n"); + mpfr_print_binary (x); + puts (""); + mpfr_print_binary (y); + puts (""); + mpfr_clear (x); + mpfr_clear (y); + exit (1); + } + + mpfr_set_str (y, "245540327e122", 10, GMP_RNDN); + mpfr_set_str_binary (x, "0.10001101101100010001100011110000110001100010111001011E434"); + if (mpfr_cmp (x, y)) + { + printf ("Error in mpfr_set_str (16):\n"); + mpfr_print_binary (x); + puts (""); + mpfr_print_binary (y); + puts (""); + mpfr_clear (x); + mpfr_clear (y); + exit (1); + } + + mpfr_set_str (y, "491080654e122", 10, GMP_RNDN); + mpfr_set_str_binary (x, "0.10001101101100010001100011110000110001100010111001011E435"); + if (mpfr_cmp (x, y)) + { + printf ("Error in mpfr_set_str (17):\n"); + mpfr_print_binary (x); + puts (""); + mpfr_print_binary (y); + puts (""); + mpfr_clear (x); + mpfr_clear (y); + exit (1); + } + + mpfr_set_str (y, "83356057653e193", 10, GMP_RNDN); + mpfr_set_str_binary (x, "0.10101010001001110011011011010111011100010101000011000E678"); + if (mpfr_cmp (x, y)) + { + printf ("Error in mpfr_set_str (18):\n"); + mpfr_print_binary (x); + puts (""); + mpfr_print_binary (y); + puts (""); + mpfr_clear (x); + mpfr_clear (y); + exit (1); + } + + CHECK53(y, "83356057653e193", GMP_RNDN, x, + "0.10101010001001110011011011010111011100010101000011000E678", + 18); + + CHECK53(y, "619534293513e124", GMP_RNDN, x, + "0.10001000011000010000000110000001111111110000011110001e452", + 19); + + CHECK53(y, "3142213164987e-294", GMP_RNDN, x, + "0.11101001101000000100111011111101111001010001001101111e-935", + 20); + + CHECK53(y, "36167929443327e-159", GMP_RNDN, x, + "0.11100111001110111110000101011001100110010100011111100e-483", + 21); + + CHECK53(y, "904198236083175e-161", GMP_RNDN, x, + "0.11100111001110111110000101011001100110010100011111100e-485", + 22); + + CHECK53(y, "3743626360493413e-165", GMP_RNDN, x, + "0.11000100000100011101001010111101011011011111011111001e-496", + 23); + + CHECK53(y, "94080055902682397e-242", GMP_RNDN, x, + "0.10110010010011000000111100011100111100110011011001010e-747", + 24); + + CHECK53(y, "7e-303", GMP_RNDD, x, + "0.10011001100111001000100110001110001000110111110001011e-1003", + 25); + CHECK53(y, "7e-303", GMP_RNDU, x, + "0.10011001100111001000100110001110001000110111110001100e-1003", + 26); + + CHECK53(y, "93e-234", GMP_RNDD, x, + "0.10010011110110010111001001111001000010000000001110101E-770", + 27); + CHECK53(y, "93e-234", GMP_RNDU, x, + "0.10010011110110010111001001111001000010000000001110110E-770", + 28); + + CHECK53(y, "755e174", GMP_RNDD, x, + "0.10111110110010011000110010011111101111000111111000101E588", + 29); + CHECK53(y, "755e174", GMP_RNDU, x, + "0.10111110110010011000110010011111101111000111111000110E588", + 30); + + CHECK53(y, "8699e-276", GMP_RNDD, x, + "0.10010110100101101111100100100011011101100110100101100E-903", + 31); + CHECK53(y, "8699e-276", GMP_RNDU, x, + "0.10010110100101101111100100100011011101100110100101101E-903", + 32); + + CHECK53(y, "82081e41", GMP_RNDD, x, + "0.10111000000010000010111011111001111010100011111001011E153", + 33); + CHECK53(y, "82081e41", GMP_RNDU, x, + "0.10111000000010000010111011111001111010100011111001100E153", + 34); + + CHECK53(y, "584169e229", GMP_RNDD, x, + "0.11101011001010111000001011001110111000111100110101010E780", + 35); + CHECK53(y, "584169e229", GMP_RNDU, x, + "0.11101011001010111000001011001110111000111100110101011E780", + 36); + + CHECK53(y, "5783893e-128", GMP_RNDD, x, + "0.10011000111100000110011110000101100111110011101110100E-402", + 37); + CHECK53(y, "5783893e-128", GMP_RNDU, x, + "0.10011000111100000110011110000101100111110011101110101E-402", + 38); + + CHECK53(y, "87575437e-310", GMP_RNDD, x, + "0.11000000001011100000110011110011010000000010001010110E-1003", + 39); + CHECK53(y, "87575437e-310", GMP_RNDU, x, + "0.11000000001011100000110011110011010000000010001010111E-1003", + 40); + + CHECK53(y, "245540327e121", GMP_RNDD, x, + "0.11100010101101001111010010110100011100000100101000100E430", + 41); + CHECK53(y, "245540327e121", GMP_RNDU, x, + "0.11100010101101001111010010110100011100000100101000101E430", + 42); + + CHECK53(y, "9078555839e-109", GMP_RNDD, x, + "0.11111110001010111010110000110011100110001010011101101E-329", + 43); + CHECK53(y, "9078555839e-109", GMP_RNDU, x, + "0.11111110001010111010110000110011100110001010011101110E-329", + 44); + + CHECK53(y, "42333842451e201", GMP_RNDD, x, + "0.10000000110001001101000100110110111110101011101011111E704", + 45); + CHECK53(y, "42333842451e201", GMP_RNDU, x, + "0.10000000110001001101000100110110111110101011101100000E704", + 46); + + CHECK53(y, "778380362293e218", GMP_RNDD, x, + "0.11001101010111000001001100001100110010000001010010010E764", + 47); + CHECK53(y, "778380362293e218", GMP_RNDU, x, + "0.11001101010111000001001100001100110010000001010010011E764", + 48); + + CHECK53(y, "7812878489261e-179", GMP_RNDD, x, + "0.10010011011011010111001111011101111101101101001110100E-551", + 49); + CHECK53(y, "7812878489261e-179", GMP_RNDU, x, + "0.10010011011011010111001111011101111101101101001110101E-551", + 50); + + CHECK53(y, "77003665618895e-73", GMP_RNDD, x, + "0.11000101111110111111001111111101001101111000000101001E-196", + 51); + CHECK53(y, "77003665618895e-73", GMP_RNDU, x, + "0.11000101111110111111001111111101001101111000000101010E-196", + 52); + + CHECK53(y, "834735494917063e-300", GMP_RNDD, x, + "0.11111110001101100001001101111100010011001110111010001E-947", + 53); + CHECK53(y, "834735494917063e-300", GMP_RNDU, x, + "0.11111110001101100001001101111100010011001110111010010E-947", + 54); + + CHECK53(y, "6182410494241627e-119", GMP_RNDD, x, + "0.10001101110010110010001011000010001000101110100000111E-342", + 55); + CHECK53(y, "6182410494241627e-119", GMP_RNDU, x, + "0.10001101110010110010001011000010001000101110100001000E-342", + 56); + + CHECK53(y, "26153245263757307e49", GMP_RNDD, x, + "0.10011110111100000000001011011110101100010000011011110E218", + 57); + CHECK53(y, "26153245263757307e49", GMP_RNDU, x, + "0.10011110111100000000001011011110101100010000011011111E218", + 58); + /* to check this problem : I convert limb (10--0 or 101--1) into base b with more than mp_bits_per_limb digits, so when convert into base 2 I should have @@ -422,7 +743,7 @@ main (int argc, char *argv[]) mpfr_set_prec (x, mp_bits_per_limb); /* x and y have only one limb */ mpfr_set_prec (y, mp_bits_per_limb); - str = (*__gmp_allocate_func) (N + 20); + str = (char*) (*__gmp_allocate_func) (N + 20); mpfr_set_ui (x, 1, GMP_RNDN); /* ensures that x is not NaN or Inf */ for (; nb_digit < N; nb_digit *= 10) @@ -486,26 +807,26 @@ main (int argc, char *argv[]) /* check invalid input */ mpfr_set_ui (x, 1, GMP_RNDN); ret = mpfr_set_str (x, "1", 37, GMP_RNDN); - MPFR_ASSERTN(mpfr_cmp_ui (x, 1) == 0 && ret == -1); + MPFR_ASSERTN (ret == -1); ret = mpfr_set_str (x, "1E10toto", 10, GMP_RNDN); - MPFR_ASSERTN(mpfr_cmp_ui (x, 1) == 0 && ret == -1); + MPFR_ASSERTN (ret == -1); ret = mpfr_set_str (x, "1p10toto", 16, GMP_RNDN); - MPFR_ASSERTN(mpfr_cmp_ui (x, 1) == 0 && ret == -1); + MPFR_ASSERTN (ret == -1); ret = mpfr_set_str (x, "", 16, GMP_RNDN); - MPFR_ASSERTN(mpfr_cmp_ui (x, 1) == 0 && ret == -1); + MPFR_ASSERTN (ret == -1); ret = mpfr_set_str (x, "+", 16, GMP_RNDN); - MPFR_ASSERTN(mpfr_cmp_ui (x, 1) == 0 && ret == -1); + MPFR_ASSERTN (ret == -1); ret = mpfr_set_str (x, "-", 16, GMP_RNDN); - MPFR_ASSERTN(mpfr_cmp_ui (x, 1) == 0 && ret == -1); + MPFR_ASSERTN (ret == -1); ret = mpfr_set_str (x, "this_is_an_invalid_number_in_base_36", 36, GMP_RNDN); - MPFR_ASSERTN(mpfr_cmp_ui (x, 1) == 0 && ret == -1); + MPFR_ASSERTN (ret == -1); ret = mpfr_set_str (x, "1.2.3", 10, GMP_RNDN); - MPFR_ASSERTN(mpfr_cmp_ui (x, 1) == 0 && ret == -1); + MPFR_ASSERTN (ret == -1); mpfr_set_prec (x, 135); ret = mpfr_set_str (x, "thisisavalidnumberinbase36", 36, GMP_RNDN); mpfr_set_prec (y, 135); mpfr_set_str (y, "23833565676460972739462619524519814462546", 10, GMP_RNDN); - MPFR_ASSERTN(mpfr_cmp (x, y) == 0 && ret == 0); + MPFR_ASSERTN (mpfr_cmp (x, y) == 0 && ret == 0); /* coverage test for set_str_binary */ mpfr_set_str_binary (x, "NaN"); diff --git a/tests/tset_z.c b/tests/tset_z.c index f0f49f5fc..afdc971a6 100644 --- a/tests/tset_z.c +++ b/tests/tset_z.c @@ -1,6 +1,6 @@ /* Test file for mpfr_set_z. -Copyright 1999, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +Copyright 1999, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -31,17 +31,18 @@ static void check0(void) mpz_t y; mpfr_t x; int inexact, r; + /* Check for +0 */ - mpfr_init(x); - mpz_init(y); - mpz_set_si(y, 0); - for(r = 0 ; r < GMP_RND_MAX ; r++) + mpfr_init (x); + mpz_init (y); + mpz_set_si (y, 0); + for(r = 0; r < GMP_RND_MAX; r++) { - inexact = mpfr_set_z(x, y, r); + inexact = mpfr_set_z (x, y, (mp_rnd_t) r); if (!MPFR_IS_ZERO(x) || !MPFR_IS_POS(x) || inexact) { printf("mpfr_set_z(x,0) failed for %s\n", - mpfr_print_rnd_mode(r)); + mpfr_print_rnd_mode ((mp_rnd_t) r)); exit(1); } } @@ -94,27 +95,27 @@ check_large (void) /* check overflow */ emax = mpfr_get_emax (); - mpfr_set_emax (2); + set_emax (2); mpz_set_str (z, "7", 10); mpfr_set_z (x, z, GMP_RNDU); MPFR_ASSERTN(mpfr_inf_p (x) && mpfr_sgn (x) > 0); - mpfr_set_emax (3); + set_emax (3); mpfr_set_prec (x, 2); mpz_set_str (z, "7", 10); mpfr_set_z (x, z, GMP_RNDU); MPFR_ASSERTN(mpfr_inf_p (x) && mpfr_sgn (x) > 0); - mpfr_set_emax (emax); + set_emax (emax); /* check underflow */ emin = mpfr_get_emin (); - mpfr_set_emin (3); + set_emin (3); mpz_set_str (z, "1", 10); mpfr_set_z (x, z, GMP_RNDZ); MPFR_ASSERTN(mpfr_cmp_ui (x, 0) == 0 && MPFR_IS_POS(x)); - mpfr_set_emin (2); + set_emin (2); mpfr_set_z (x, z, GMP_RNDN); MPFR_ASSERTN(mpfr_cmp_ui (x, 0) == 0 && MPFR_IS_POS(x)); - mpfr_set_emin (emin); + set_emin (emin); mpz_clear (z); mpfr_clear (x); @@ -129,11 +130,12 @@ main (int argc, char *argv[]) tests_start_mpfr (); check_large (); - check (0, 0); + check (0, (mp_rnd_t) 0); for (j = 0; j < 200000; j++) - check (randlimb () & LONG_MAX, RND_RAND () ); - check0(); + check (randlimb () & LONG_MAX, (mp_rnd_t) RND_RAND ()); + check0 (); tests_end_mpfr (); + return 0; } diff --git a/tests/tsqr.c b/tests/tsqr.c index 037844503..a768143b9 100644 --- a/tests/tsqr.c +++ b/tests/tsqr.c @@ -1,6 +1,6 @@ /* Test file for mpfr_sqr. -Copyright 2004 Free Software Foundation. +Copyright 2004, 2005 Free Software Foundation. This file is part of the MPFR Library. @@ -66,7 +66,7 @@ error2 (mp_rnd_t rnd, mpfr_prec_t prec, mpfr_t in, mpfr_t out, void check_random(mpfr_prec_t p) { mpfr_t x,y,z; - mp_rnd_t r; + int r; int i, inexact1, inexact2; mpfr_inits2(p, x, y, z, NULL); @@ -74,14 +74,14 @@ void check_random(mpfr_prec_t p) { mpfr_random (x); if (MPFR_IS_PURE_FP(x)) - for(r = 0 ; r < GMP_RND_MAX ; r++) + for (r = 0 ; r < GMP_RND_MAX ; r++) { - inexact1 = mpfr_mul (y, x, x, r); - inexact2 = mpfr_sqr (z, x, r); - if (mpfr_cmp(y, z)) - error1 (r,p,x,y,z); + inexact1 = mpfr_mul (y, x, x, (mp_rnd_t) r); + inexact2 = mpfr_sqr (z, x, (mp_rnd_t) r); + if (mpfr_cmp (y, z)) + error1 ((mp_rnd_t) r,p,x,y,z); if (inexact1 != inexact2) - error2 (r,p,x,y,inexact1,inexact2); + error2 ((mp_rnd_t) r,p,x,y,inexact1,inexact2); } } mpfr_clears(x,y,z,NULL); diff --git a/tests/tsqrt.c b/tests/tsqrt.c index 85a030ad0..cdbd5dc70 100644 --- a/tests/tsqrt.c +++ b/tests/tsqrt.c @@ -1,6 +1,6 @@ /* Test file for mpfr_sqrt. -Copyright 1999, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +Copyright 1999, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -304,7 +304,7 @@ check_inexact (mp_prec_t p) mpfr_init2 (y, p); mpfr_init2 (z, 2*p); mpfr_random (x); - rnd = RND_RAND(); + rnd = (mp_rnd_t) RND_RAND(); inexact = mpfr_sqrt (y, x, rnd); if (mpfr_mul (z, y, y, rnd)) /* exact since prec(z) = 2*prec(y) */ { diff --git a/tests/tstrtofr.c b/tests/tstrtofr.c index 29cad883b..f88542ed6 100644 --- a/tests/tstrtofr.c +++ b/tests/tstrtofr.c @@ -142,6 +142,7 @@ check_special (void) } /* Check base 62 */ +#if 0 res = mpfr_strtofr (x, "A", NULL, 62, GMP_RNDN); if (res != 0 || mpfr_cmp_ui (x, 10)) { @@ -174,6 +175,7 @@ check_special (void) putchar ('\n'); exit (1); } +#endif mpfr_clear (x); mpfr_clear (y); diff --git a/tests/tsub.c b/tests/tsub.c index 9d5430beb..bdf14e00a 100644 --- a/tests/tsub.c +++ b/tests/tsub.c @@ -1,6 +1,6 @@ /* Test file for mpfr_sub. -Copyright 2001, 2002, 2003, 2004 Free Software Foundation. +Copyright 2001, 2002, 2003, 2004, 2005 Free Software Foundation. This file is part of the MPFR Library. @@ -411,14 +411,14 @@ check_inexact (void) : MPFR_EXP(u) - MPFR_EXP(x); pz = pz + MAX(MPFR_PREC(x), MPFR_PREC(u)); mpfr_set_prec (z, pz); - rnd = RND_RAND(); + rnd = (mp_rnd_t) RND_RAND(); if (mpfr_sub (z, x, u, rnd)) { printf ("z <- x - u should be exact\n"); exit (1); } { - rnd = RND_RAND (); + rnd = (mp_rnd_t) RND_RAND (); inexact = mpfr_sub (y, x, u, rnd); cmp = mpfr_cmp (y, z); if (((inexact == 0) && (cmp != 0)) || diff --git a/tests/tsub1sp.c b/tests/tsub1sp.c index 3983a9f6a..3f92a87c9 100644 --- a/tests/tsub1sp.c +++ b/tests/tsub1sp.c @@ -1,6 +1,6 @@ /* Test file for mpfr_sub1sp. -Copyright 2003, 2004 Free Software Foundation. +Copyright 2003, 2004, 2005 Free Software Foundation. This file is part of the MPFR Library. @@ -34,7 +34,7 @@ int main(void) tests_start_mpfr (); check_special (); - for(p = 2 ; p < 200 ; p++) + for (p = 2 ; p < 200 ; p++) check_random (p); tests_end_mpfr (); @@ -44,49 +44,49 @@ int main(void) #define STD_ERROR \ {\ printf("ERROR: for %s and p=%lu and i=%d:\nY=",\ - mpfr_print_rnd_mode(r), p, i);\ - mpfr_print_binary(y);\ - printf("\nZ="); mpfr_print_binary(z);\ - printf("\nReal: "); mpfr_print_binary(x2);\ - printf("\nGot : "); mpfr_print_binary(x);\ - putchar('\n');\ + mpfr_print_rnd_mode ((mp_rnd_t) r), p, i);\ + mpfr_print_binary(y);\ + printf("\nZ="); mpfr_print_binary(z);\ + printf("\nReal: "); mpfr_print_binary(x2);\ + printf("\nGot : "); mpfr_print_binary(x);\ + putchar('\n');\ exit(1);\ } #define STD_ERROR2 \ {\ printf("ERROR: for %s and p=%lu and i=%d:\nY=",\ - mpfr_print_rnd_mode(r), p, i);\ + mpfr_print_rnd_mode ((mp_rnd_t) r), p, i);\ mpfr_print_binary(y);\ printf("\nZ="); mpfr_print_binary(z);\ printf("\nR="); mpfr_print_binary(x);\ printf("\nWrong inexact flag. Real: %d. Got: %d\n", \ - inexact1, inexact2); \ + inexact1, inexact2); \ exit(1);\ } void check_random(mpfr_prec_t p) { mpfr_t x,y,z,x2; - mp_rnd_t r; + int r; int i, inexact1, inexact2; mpfr_inits2(p, x,y,z,x2,NULL); - for(i = 0 ; i < 500 ; i++) + for (i = 0 ; i < 500 ; i++) { mpfr_random (y); mpfr_random (z); if (MPFR_IS_PURE_FP(y) && MPFR_IS_PURE_FP(z)) - for(r = 0 ; r < GMP_RND_MAX ; r++) - { - inexact1 = mpfr_sub1(x2, y, z, r); - inexact2 = mpfr_sub1sp(x, y, z, r); - if (mpfr_cmp(x, x2)) - STD_ERROR; - if (inexact1 != inexact2) - STD_ERROR2; - } + for(r = 0 ; r < GMP_RND_MAX ; r++) + { + inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r); + inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r); + if (mpfr_cmp(x, x2)) + STD_ERROR; + if (inexact1 != inexact2) + STD_ERROR2; + } } mpfr_clears(x,y,z,x2,NULL); @@ -95,14 +95,14 @@ void check_random(mpfr_prec_t p) void check_special(void) { mpfr_t x,y,z,x2; - mp_rnd_t r; + int r; mpfr_prec_t p; int i = -1, inexact1, inexact2; mp_exp_t es; mpfr_inits(x,y,z,x2,NULL); - for(r = 0 ; r < GMP_RND_MAX ; r++) + for (r = 0 ; r < GMP_RND_MAX ; r++) { p = 53; mpfr_set_prec(x, 53); @@ -110,397 +110,396 @@ void check_special(void) mpfr_set_prec(y, 53); mpfr_set_prec(z, 53); - mpfr_set_str_binary (y, + mpfr_set_str_binary (y, "0.10110111101101110010010010011011000001101101011011001E31"); - - mpfr_sub1sp(x, y, y, r); + + mpfr_sub1sp (x, y, y, (mp_rnd_t) r); if (mpfr_cmp_ui(x, 0)) - { - printf("Error for x-x with p=%lu. Expected 0. Got:", p); - mpfr_print_binary(x); - exit(1); - } - - mpfr_set(z, y, r); - mpfr_sub1sp(x, y, z, r); + { + printf("Error for x-x with p=%lu. Expected 0. Got:", p); + mpfr_print_binary(x); + exit(1); + } + + mpfr_set(z, y, (mp_rnd_t) r); + mpfr_sub1sp(x, y, z, (mp_rnd_t) r); if (mpfr_cmp_ui(x, 0)) - { - printf("Error for x-y with y=x and p=%lu. Expected 0. Got:", p); - mpfr_print_binary(x); - exit(1); - } + { + printf("Error for x-y with y=x and p=%lu. Expected 0. Got:", p); + mpfr_print_binary(x); + exit(1); + } /* diff = 0 */ mpfr_set_str_binary (y, "0.10110111101101110010010010011011001001101101011011001E31"); - inexact1 = mpfr_sub1(x2, y, z, r); - inexact2 = mpfr_sub1sp(x, y, z, r); + inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r); + inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r); if (mpfr_cmp(x, x2)) - STD_ERROR; + STD_ERROR; if (inexact1 != inexact2) - STD_ERROR2; - + STD_ERROR2; + /* Diff = 1 */ mpfr_set_str_binary (y, "0.10110111101101110010010010011011000001101101011011001E30"); - inexact1 = mpfr_sub1(x2, y, z, r); - inexact2 = mpfr_sub1sp(x, y, z, r); + inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r); + inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r); if (mpfr_cmp(x, x2)) - STD_ERROR; + STD_ERROR; if (inexact1 != inexact2) - STD_ERROR2; - + STD_ERROR2; + /* Diff = 2 */ mpfr_set_str_binary (y, "0.10110111101101110010010010011011000101101101011011001E32"); - inexact1 = mpfr_sub1(x2, y, z, r); - inexact2 = mpfr_sub1sp(x, y, z, r); + inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r); + inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r); if (mpfr_cmp(x, x2)) - STD_ERROR; + STD_ERROR; if (inexact1 != inexact2) - STD_ERROR2; - + STD_ERROR2; + /* Diff = 32 */ mpfr_set_str_binary (y, "0.10110111101101110010010010011011000001101101011011001E63"); - inexact1 = mpfr_sub1(x2, y, z, r); - inexact2 = mpfr_sub1sp(x, y, z, r); + inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r); + inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r); if (mpfr_cmp(x, x2)) - STD_ERROR; + STD_ERROR; if (inexact1 != inexact2) - STD_ERROR2; - + STD_ERROR2; + /* Diff = 52 */ mpfr_set_str_binary (y, "0.10110111101101110010010010011011010001101101011011001E83"); - inexact1 = mpfr_sub1(x2, y, z, r); - inexact2 = mpfr_sub1sp(x, y, z, r); + inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r); + inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r); if (mpfr_cmp(x, x2)) - STD_ERROR; + STD_ERROR; if (inexact1 != inexact2) - STD_ERROR2; - + STD_ERROR2; + /* Diff = 53 */ mpfr_set_str_binary (y, "0.10110111101101110010010010011111000001101101011011001E31"); - inexact1 = mpfr_sub1(x2, y, z, r); - inexact2 = mpfr_sub1sp(x, y, z, r); + inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r); + inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r); if (mpfr_cmp(x, x2)) STD_ERROR; if (inexact1 != inexact2) - STD_ERROR2; + STD_ERROR2; /* Diff > 200 */ mpfr_set_str_binary (y, "0.10110111101101110010010010011011000001101101011011001E331"); - inexact1 = mpfr_sub1(x2, y, z, r); - inexact2 = mpfr_sub1sp(x, y, z, r); + inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r); + inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r); if (mpfr_cmp(x, x2)) - STD_ERROR; + STD_ERROR; if (inexact1 != inexact2) - STD_ERROR2; + STD_ERROR2; - mpfr_set_str_binary (y, + mpfr_set_str_binary (y, "0.10000000000000000000000000000000000000000000000000000E31"); - mpfr_set_str_binary (z, + mpfr_set_str_binary (z, "0.11111111111111111111111111111111111111111111111111111E30"); - inexact1 = mpfr_sub1(x2, y, z, r); - inexact2 = mpfr_sub1sp(x, y, z, r); - if (mpfr_cmp(x, x2)) - STD_ERROR; - if (inexact1 != inexact2) - STD_ERROR2; - - mpfr_set_str_binary (y, + inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r); + inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r); + if (mpfr_cmp(x, x2)) + STD_ERROR; + if (inexact1 != inexact2) + STD_ERROR2; + + mpfr_set_str_binary (y, "0.10000000000000000000000000000000000000000000000000000E31"); - mpfr_set_str_binary (z, + mpfr_set_str_binary (z, "0.11111111111111111111111111111111111111111111111111111E29"); - inexact1 = mpfr_sub1(x2, y, z, r); - inexact2 = mpfr_sub1sp(x, y, z, r); - if (mpfr_cmp(x, x2)) - STD_ERROR; - if (inexact1 != inexact2) - STD_ERROR2; - - mpfr_set_str_binary (y, + inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r); + inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r); + if (mpfr_cmp(x, x2)) + STD_ERROR; + if (inexact1 != inexact2) + STD_ERROR2; + + mpfr_set_str_binary (y, "0.10000000000000000000000000000000000000000000000000000E52"); - mpfr_set_str_binary (z, + mpfr_set_str_binary (z, "0.10000000000010000000000000000000000000000000000000000E00"); - inexact1 = mpfr_sub1(x2, y, z, r); - inexact2 = mpfr_sub1sp(x, y, z, r); - if (mpfr_cmp(x, x2)) - STD_ERROR; - if (inexact1 != inexact2) - STD_ERROR2; - - mpfr_set_str_binary (y, - "0.11100000000000000000000000000000000000000000000000000E53"); - mpfr_set_str_binary (z, - "0.10000000000000000000000000000000000000000000000000000E00"); - inexact1 = mpfr_sub1(x2, y, z, r); - inexact2 = mpfr_sub1sp(z, y, z, r); - mpfr_set(x, z, r); - if (mpfr_cmp(x, x2)) - STD_ERROR; - if (inexact1 != inexact2) - STD_ERROR2; - - mpfr_set_str_binary (y, + inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r); + inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r); + if (mpfr_cmp(x, x2)) + STD_ERROR; + if (inexact1 != inexact2) + STD_ERROR2; + + mpfr_set_str_binary (y, + "0.11100000000000000000000000000000000000000000000000000E53"); + mpfr_set_str_binary (z, + "0.10000000000000000000000000000000000000000000000000000E00"); + inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r); + inexact2 = mpfr_sub1sp(z, y, z, (mp_rnd_t) r); + mpfr_set(x, z, (mp_rnd_t) r); + if (mpfr_cmp(x, x2)) + STD_ERROR; + if (inexact1 != inexact2) + STD_ERROR2; + + mpfr_set_str_binary (y, "0.10000000000000000000000000000000000000000000000000000E53"); - mpfr_set_str_binary (z, + mpfr_set_str_binary (z, "0.10100000000000000000000000000000000000000000000000000E00"); - inexact1 = mpfr_sub1(x2, y, z, r); - inexact2 = mpfr_sub1sp(x, y, z, r); - if (mpfr_cmp(x, x2)) - STD_ERROR; - if (inexact1 != inexact2) - STD_ERROR2; - - mpfr_set_str_binary (y, - "0.10000000000000000000000000000000000000000000000000000E54"); - mpfr_set_str_binary (z, - "0.10100000000000000000000000000000000000000000000000000E00"); - inexact1 = mpfr_sub1(x2, y, z, r); - inexact2 = mpfr_sub1sp(x, y, z, r); - if (mpfr_cmp(x, x2)) - STD_ERROR; - if (inexact1 != inexact2) - STD_ERROR2; - - p = 63; - mpfr_set_prec(x, p); - mpfr_set_prec(x2, p); - mpfr_set_prec(y, p); - mpfr_set_prec(z, p); - mpfr_set_str_binary (y, + inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r); + inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r); + if (mpfr_cmp(x, x2)) + STD_ERROR; + if (inexact1 != inexact2) + STD_ERROR2; + + mpfr_set_str_binary (y, + "0.10000000000000000000000000000000000000000000000000000E54"); + mpfr_set_str_binary (z, + "0.10100000000000000000000000000000000000000000000000000E00"); + inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r); + inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r); + if (mpfr_cmp(x, x2)) + STD_ERROR; + if (inexact1 != inexact2) + STD_ERROR2; + + p = 63; + mpfr_set_prec(x, p); + mpfr_set_prec(x2, p); + mpfr_set_prec(y, p); + mpfr_set_prec(z, p); + mpfr_set_str_binary (y, "0.100000000000000000000000000000000000000000000000000000000000000E62"); - mpfr_set_str_binary (z, + mpfr_set_str_binary (z, "0.110000000000000000000000000000000000000000000000000000000000000E00"); - inexact1 = mpfr_sub1(x2, y, z, r); - inexact2 = mpfr_sub1sp(x, y, z, r); - if (mpfr_cmp(x, x2)) - STD_ERROR; - if (inexact1 != inexact2) - STD_ERROR2; - - p = 64; - mpfr_set_prec(x, 64); - mpfr_set_prec(x2, 64); - mpfr_set_prec(y, 64); - mpfr_set_prec(z, 64); - - mpfr_set_str_binary (y, + inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r); + inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r); + if (mpfr_cmp(x, x2)) + STD_ERROR; + if (inexact1 != inexact2) + STD_ERROR2; + + p = 64; + mpfr_set_prec(x, 64); + mpfr_set_prec(x2, 64); + mpfr_set_prec(y, 64); + mpfr_set_prec(z, 64); + + mpfr_set_str_binary (y, "0.1100000000000000000000000000000000000000000000000000000000000000E31"); - mpfr_set_str_binary (z, + mpfr_set_str_binary (z, "0.1111111111111111111111111110000000000000000000000000011111111111E29"); - inexact1 = mpfr_sub1(x2, y, z, r); - inexact2 = mpfr_sub1sp(x, y, z, r); - if (mpfr_cmp(x, x2)) - STD_ERROR; - if (inexact1 != inexact2) - STD_ERROR2; - - mpfr_set_str_binary (y, + inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r); + inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r); + if (mpfr_cmp(x, x2)) + STD_ERROR; + if (inexact1 != inexact2) + STD_ERROR2; + + mpfr_set_str_binary (y, "0.1000000000000000000000000000000000000000000000000000000000000000E63"); - mpfr_set_str_binary (z, + mpfr_set_str_binary (z, "0.1011000000000000000000000000000000000000000000000000000000000000E00"); - inexact1 = mpfr_sub1(x2, y, z, r); - inexact2 = mpfr_sub1sp(x, y, z, r); - if (mpfr_cmp(x, x2)) - STD_ERROR; - if (inexact1 != inexact2) - STD_ERROR2; - - mpfr_set_str_binary (y, + inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r); + inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r); + if (mpfr_cmp(x, x2)) + STD_ERROR; + if (inexact1 != inexact2) + STD_ERROR2; + + mpfr_set_str_binary (y, "0.1000000000000000000000000000000000000000000000000000000000000000E63"); - mpfr_set_str_binary (z, + mpfr_set_str_binary (z, "0.1110000000000000000000000000000000000000000000000000000000000000E00"); - inexact1 = mpfr_sub1(x2, y, z, r); - inexact2 = mpfr_sub1sp(x, y, z, r); - if (mpfr_cmp(x, x2)) - STD_ERROR; - if (inexact1 != inexact2) - STD_ERROR2; - - mpfr_set_str_binary (y, + inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r); + inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r); + if (mpfr_cmp(x, x2)) + STD_ERROR; + if (inexact1 != inexact2) + STD_ERROR2; + + mpfr_set_str_binary (y, "0.10000000000000000000000000000000000000000000000000000000000000E63"); - mpfr_set_str_binary (z, + mpfr_set_str_binary (z, "0.10000000000000000000000000000000000000000000000000000000000000E00"); - inexact1 = mpfr_sub1(x2, y, z, r); - inexact2 = mpfr_sub1sp(x, y, z, r); - if (mpfr_cmp(x, x2)) - STD_ERROR; - if (inexact1 != inexact2) - STD_ERROR2; - - mpfr_set_str_binary (y, + inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r); + inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r); + if (mpfr_cmp(x, x2)) + STD_ERROR; + if (inexact1 != inexact2) + STD_ERROR2; + + mpfr_set_str_binary (y, "0.1000000000000000000000000000000000000000000000000000000000000000E64"); - mpfr_set_str_binary (z, + mpfr_set_str_binary (z, "0.1010000000000000000000000000000000000000000000000000000000000000E00"); - inexact1 = mpfr_sub1(x2, y, z, r); - inexact2 = mpfr_sub1sp(x, y, z, r); - if (mpfr_cmp(x, x2)) - STD_ERROR; - if (inexact1 != inexact2) - STD_ERROR2; - - MPFR_SET_NAN(x); - MPFR_SET_NAN(x2); - mpfr_set_str_binary (y, + inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r); + inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r); + if (mpfr_cmp(x, x2)) + STD_ERROR; + if (inexact1 != inexact2) + STD_ERROR2; + + MPFR_SET_NAN(x); + MPFR_SET_NAN(x2); + mpfr_set_str_binary (y, "0.1000000000000000000000000000000000000000000000000000000000000000" - "E-1073741823"); - mpfr_set_str_binary (z, + "E-1073741823"); + mpfr_set_str_binary (z, "0.1100000000000000000000000000000000000000000000000000000000000000" - "E-1073741823"); - inexact1 = mpfr_sub1(x2, y, z, r); - inexact2 = mpfr_sub1sp(x, y, z, r); - if (mpfr_cmp(x, x2)) - STD_ERROR; - if (inexact1 != inexact2) - STD_ERROR2; - - p = 9; - mpfr_set_prec(x, p); - mpfr_set_prec(x2, p); - mpfr_set_prec(y, p); - mpfr_set_prec(z, p); - - mpfr_set_str_binary (y, "0.100000000E1"); - mpfr_set_str_binary (z, "0.100000000E-8"); - inexact1 = mpfr_sub1(x2, y, z, r); - inexact2 = mpfr_sub1sp(x, y, z, r); - if (mpfr_cmp(x, x2)) - STD_ERROR; - if (inexact1 != inexact2) - STD_ERROR2; - - p = 34; - mpfr_set_prec(x, p); - mpfr_set_prec(x2, p); - mpfr_set_prec(y, p); - mpfr_set_prec(z, p); - - mpfr_set_str_binary (y, "-0.1011110000111100010111011100110100E-18"); - mpfr_set_str_binary (z, "0.1000101010110011010101011110000000E-14"); - inexact1 = mpfr_sub1(x2, y, z, r); - inexact2 = mpfr_sub1sp(x, y, z, r); - if (mpfr_cmp(x, x2)) - STD_ERROR; - if (inexact1 != inexact2) - STD_ERROR2; - - p = 124; - mpfr_set_prec(x, p); - mpfr_set_prec(x2, p); - mpfr_set_prec(y, p); - mpfr_set_prec(z, p); - - mpfr_set_str_binary (y, + "E-1073741823"); + inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r); + inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r); + if (mpfr_cmp(x, x2)) + STD_ERROR; + if (inexact1 != inexact2) + STD_ERROR2; + + p = 9; + mpfr_set_prec(x, p); + mpfr_set_prec(x2, p); + mpfr_set_prec(y, p); + mpfr_set_prec(z, p); + + mpfr_set_str_binary (y, "0.100000000E1"); + mpfr_set_str_binary (z, "0.100000000E-8"); + inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r); + inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r); + if (mpfr_cmp(x, x2)) + STD_ERROR; + if (inexact1 != inexact2) + STD_ERROR2; + + p = 34; + mpfr_set_prec(x, p); + mpfr_set_prec(x2, p); + mpfr_set_prec(y, p); + mpfr_set_prec(z, p); + + mpfr_set_str_binary (y, "-0.1011110000111100010111011100110100E-18"); + mpfr_set_str_binary (z, "0.1000101010110011010101011110000000E-14"); + inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r); + inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r); + if (mpfr_cmp(x, x2)) + STD_ERROR; + if (inexact1 != inexact2) + STD_ERROR2; + + p = 124; + mpfr_set_prec(x, p); + mpfr_set_prec(x2, p); + mpfr_set_prec(y, p); + mpfr_set_prec(z, p); + + mpfr_set_str_binary (y, "0.1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E1"); - mpfr_set_str_binary (z, + mpfr_set_str_binary (z, "0.1011111000100111000011001000011101010101101100101010101001000001110100001101110110001110111010000011101001100010111110001100E-31"); - inexact1 = mpfr_sub1(x2, y, z, r); - inexact2 = mpfr_sub1sp(x, y, z, r); - if (mpfr_cmp(x, x2)) - STD_ERROR; - if (inexact1 != inexact2) - STD_ERROR2; - - p = 288; - mpfr_set_prec(x, p); - mpfr_set_prec(x2, p); - mpfr_set_prec(y, p); - mpfr_set_prec(z, p); - - mpfr_set_str_binary (y, + inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r); + inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r); + if (mpfr_cmp(x, x2)) + STD_ERROR; + if (inexact1 != inexact2) + STD_ERROR2; + + p = 288; + mpfr_set_prec(x, p); + mpfr_set_prec(x2, p); + mpfr_set_prec(y, p); + mpfr_set_prec(z, p); + + mpfr_set_str_binary (y, "0.111000110011000001000111101010111011110011101001101111111110000011100101000001001010110010101010011001010100000001110011110001010101101010001011101110100100001011110100110000101101100011010001001011011010101010000010001101001000110010010111111011110001111101001000101101001100101100101000E80"); - mpfr_set_str_binary (z, + mpfr_set_str_binary (z, "-0.100001111111101001011010001100110010100111001110000110011101001011010100001000000100111011010110110010000000000010101101011000010000110001110010100001100101011100100100001011000100011110000001010101000100011101001000010111100000111000111011001000100100011000100000010010111000000100100111E-258"); - inexact1 = mpfr_sub1(x2, y, z, r); - inexact2 = mpfr_sub1sp(x, y, z, r); - if (mpfr_cmp(x, x2)) - STD_ERROR; - if (inexact1 != inexact2) - STD_ERROR2; - - p = 85; - mpfr_set_prec(x, p); - mpfr_set_prec(x2, p); - mpfr_set_prec(y, p); - mpfr_set_prec(z, p); - - mpfr_set_str_binary (y, + inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r); + inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r); + if (mpfr_cmp(x, x2)) + STD_ERROR; + if (inexact1 != inexact2) + STD_ERROR2; + + p = 85; + mpfr_set_prec(x, p); + mpfr_set_prec(x2, p); + mpfr_set_prec(y, p); + mpfr_set_prec(z, p); + + mpfr_set_str_binary (y, "0.1111101110100110110110100010101011101001100010100011110110110010010011101100101111100E-4"); - mpfr_set_str_binary (z, + mpfr_set_str_binary (z, "0.1111101110100110110110100010101001001000011000111000011101100101110100001110101010110E-4"); - inexact1 = mpfr_sub1(x2, y, z, r); - inexact2 = mpfr_sub1sp(x, y, z, r); - if (mpfr_cmp(x, x2)) - STD_ERROR; - if (inexact1 != inexact2) - STD_ERROR2; - - p = 64; - mpfr_set_prec(x, p); mpfr_set_prec(x2, p); - mpfr_set_prec(y, p); mpfr_set_prec(z, p); - - mpfr_set_str_binary (y, - "0.11000000000000000000000000000000" - "00000000000000000000000000000000E1"); - mpfr_set_str_binary (z, - "0.10000000000000000000000000000000" + inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r); + inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r); + if (mpfr_cmp(x, x2)) + STD_ERROR; + if (inexact1 != inexact2) + STD_ERROR2; + + p = 64; + mpfr_set_prec(x, p); mpfr_set_prec(x2, p); + mpfr_set_prec(y, p); mpfr_set_prec(z, p); + + mpfr_set_str_binary (y, + "0.11000000000000000000000000000000" + "00000000000000000000000000000000E1"); + mpfr_set_str_binary (z, + "0.10000000000000000000000000000000" "00000000000000000000000000000001E0"); - inexact1 = mpfr_sub1(x2, y, z, r); - inexact2 = mpfr_sub1sp(x, y, z, r); - if (mpfr_cmp(x, x2)) - STD_ERROR; - if (inexact1 != inexact2) - STD_ERROR2; - - mpfr_set_str_binary (y, - "0.11000000000000000000000000000000" + inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r); + inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r); + if (mpfr_cmp(x, x2)) + STD_ERROR; + if (inexact1 != inexact2) + STD_ERROR2; + + mpfr_set_str_binary (y, + "0.11000000000000000000000000000000" "000000000000000000000000000001E1"); - mpfr_set_str_binary (z, - "0.10000000000000000000000000000000" + mpfr_set_str_binary (z, + "0.10000000000000000000000000000000" "00000000000000000000000000000001E0"); - inexact1 = mpfr_sub1(x2, y, z, r); - inexact2 = mpfr_sub1sp(x, y, z, r); - if (mpfr_cmp(x, x2)) - STD_ERROR; - if (inexact1 != inexact2) - STD_ERROR2; - - es = mpfr_get_emin (); - mpfr_set_emin (-1024); - - mpfr_set_str_binary (y, - "0.10000000000000000000000000000000" + inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r); + inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r); + if (mpfr_cmp(x, x2)) + STD_ERROR; + if (inexact1 != inexact2) + STD_ERROR2; + + es = mpfr_get_emin (); + set_emin (-1024); + + mpfr_set_str_binary (y, + "0.10000000000000000000000000000000" "000000000000000000000000000000E-1023"); - mpfr_set_str_binary (z, - "0.10000000000000000000000000000000" + mpfr_set_str_binary (z, + "0.10000000000000000000000000000000" "00000000000000000000000000000001E-1023"); - inexact1 = mpfr_sub1(x2, y, z, r); - inexact2 = mpfr_sub1sp(x, y, z, r); - if (mpfr_cmp(x, x2)) - STD_ERROR; - if (inexact1 != inexact2) - STD_ERROR2; - - mpfr_set_str_binary (y, - "0.10000000000000000000000000000000" - "000000000000000000000000000000E-1023"); - mpfr_set_str_binary (z, - "0.1000000000000000000000000000000" - "000000000000000000000000000000E-1023"); - inexact1 = mpfr_sub1(x2, y, z, r); - inexact2 = mpfr_sub1sp(x, y, z, r); - if (mpfr_cmp(x, x2)) - STD_ERROR; - if (inexact1 != inexact2) - STD_ERROR2; + inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r); + inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r); + if (mpfr_cmp(x, x2)) + STD_ERROR; + if (inexact1 != inexact2) + STD_ERROR2; - mpfr_set_emin(es); + mpfr_set_str_binary (y, + "0.10000000000000000000000000000000" + "000000000000000000000000000000E-1023"); + mpfr_set_str_binary (z, + "0.1000000000000000000000000000000" + "000000000000000000000000000000E-1023"); + inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r); + inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r); + if (mpfr_cmp(x, x2)) + STD_ERROR; + if (inexact1 != inexact2) + STD_ERROR2; + set_emin (es); } - mpfr_clears(x,y,z,x2,NULL); + mpfr_clears(x,y,z,x2,NULL); } diff --git a/tests/tsum.c b/tests/tsum.c index 058ae9aff..78664589b 100644 --- a/tests/tsum.c +++ b/tests/tsum.c @@ -1,6 +1,6 @@ /* tsum -- test file for the list summation function -Copyright 2004 Free Software Foundation. +Copyright 2004, 2005 Free Software Foundation. This file is part of the MPFR Library. @@ -100,7 +100,7 @@ main (void) mpfr_ptr *tabtmp; unsigned long i, n; mp_prec_t f; - mp_rnd_t rnd_mode; + int rnd_mode; mpfr_srcptr *perm; mpfr_t sum, real_sum, real_non_rounded; @@ -118,8 +118,8 @@ main (void) algo_exact (real_non_rounded, tab, n, f); for (rnd_mode = 0; rnd_mode < GMP_RND_MAX; rnd_mode++) { - mpfr_list_sum (sum, tab, n, rnd_mode); - mpfr_set (real_sum, real_non_rounded, rnd_mode); + mpfr_list_sum (sum, tab, n, (mp_rnd_t) rnd_mode); + mpfr_set (real_sum, real_non_rounded, (mp_rnd_t) rnd_mode); if (mpfr_cmp (real_sum, sum) != 0) { printf ("mpfr_list_sum incorrect.\n"); @@ -142,8 +142,8 @@ main (void) for (rnd_mode = 0; rnd_mode < GMP_RND_MAX; rnd_mode++) { - mpfr_list_sum (sum, tab, n, rnd_mode); - mpfr_set (real_sum, real_non_rounded, rnd_mode); + mpfr_list_sum (sum, tab, n, (mp_rnd_t) rnd_mode); + mpfr_set (real_sum, real_non_rounded, (mp_rnd_t) rnd_mode); if (mpfr_cmp (real_sum, sum) != 0) { printf ("mpfr_list_sum incorrect.\n"); diff --git a/tests/ttanh.c b/tests/ttanh.c index c99c8331c..f66aa170c 100644 --- a/tests/ttanh.c +++ b/tests/ttanh.c @@ -60,8 +60,8 @@ special_overflow (void) { mpfr_t x, y; - mpfr_set_emin (-125); - mpfr_set_emax (128); + set_emin (-125); + set_emax (128); mpfr_init2 (x, 24); mpfr_init2 (y, 24); mpfr_set_str_binary (x, "0.101100100000000000110100E7"); @@ -74,8 +74,8 @@ special_overflow (void) } mpfr_clear (y); mpfr_clear (x); - mpfr_set_emin (MPFR_EMIN_MIN); - mpfr_set_emax (MPFR_EMAX_MAX); + set_emin (MPFR_EMIN_MIN); + set_emax (MPFR_EMAX_MAX); } int diff --git a/tests/tui_div.c b/tests/tui_div.c index ed2777442..ff5d67c86 100644 --- a/tests/tui_div.c +++ b/tests/tui_div.c @@ -1,6 +1,6 @@ /* Test file for mpfr_ui_div. -Copyright 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +Copyright 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -51,7 +51,7 @@ check_inexact (void) mp_prec_t px, py; int inexact, cmp; unsigned long int u; - mp_rnd_t rnd; + int rnd; mpfr_init (x); mpfr_init (y); @@ -72,8 +72,8 @@ check_inexact (void) mpfr_set_prec (z, py + px); for (rnd = 0; rnd < GMP_RND_MAX; rnd++) { - inexact = mpfr_ui_div (y, u, x, rnd); - if (mpfr_mul (z, y, x, rnd)) + inexact = mpfr_ui_div (y, u, x, (mp_rnd_t) rnd); + if (mpfr_mul (z, y, x, (mp_rnd_t) rnd)) { printf ("z <- y * x should be exact\n"); exit (1); @@ -84,7 +84,7 @@ check_inexact (void) ((inexact < 0) && (cmp >= 0))) { printf ("Wrong inexact flag for u=%lu, rnd=%s\n", - u, mpfr_print_rnd_mode (rnd)); + u, mpfr_print_rnd_mode ((mp_rnd_t) rnd)); printf ("expected %d, got %d\n", cmp, inexact); printf ("x="); mpfr_print_binary (x); puts (""); printf ("y="); mpfr_print_binary (y); puts (""); diff --git a/tests/tui_pow.c b/tests/tui_pow.c index 99aebef56..4546e676c 100644 --- a/tests/tui_pow.c +++ b/tests/tui_pow.c @@ -1,6 +1,6 @@ /* Test file for mpfr_ui_pow and mpfr_ui_pow_ui. -Copyright 2001, 2002, 2003, 2004 Free Software Foundation. +Copyright 2001, 2002, 2003, 2004, 2005 Free Software Foundation. Adapted from tarctan.c. This file is part of the MPFR Library. @@ -221,7 +221,7 @@ main (int argc, char *argv[]) int nt; nt = randlimb () & INT_MAX; mpfr_random (x); - rnd = RND_RAND (); + rnd = (mp_rnd_t) RND_RAND (); check1 (x, prec, nt, rnd); } } diff --git a/tests/tui_sub.c b/tests/tui_sub.c index f5978c7b8..3df03ce04 100644 --- a/tests/tui_sub.c +++ b/tests/tui_sub.c @@ -1,6 +1,6 @@ /* Test file for mpfr_ui_sub. -Copyright 2000, 2001, 2002, 2003, 2004 Free Software Foundation. +Copyright 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation. This file is part of the MPFR Library. @@ -129,6 +129,12 @@ special (void) else MPFR_ASSERTN(mpfr_cmpabs (x, y) == 0 && mpfr_sgn (x) != mpfr_sgn (y)); + mpfr_set_prec (x, 73); + mpfr_set_str_binary (x, "0.1101111010101011011011100011010000000101110001011111001011011000101111101E-99"); + mpfr_ui_sub (x, 1, x, GMP_RNDZ); + mpfr_nextabove (x); + MPFR_ASSERTN(mpfr_cmp_ui (x, 1) == 0); + mpfr_clear (x); mpfr_clear (y); mpfr_clear (res); diff --git a/tests/tzeta.c b/tests/tzeta.c index 1519b26c0..efc4b999f 100644 --- a/tests/tzeta.c +++ b/tests/tzeta.c @@ -1,6 +1,6 @@ /* tzeta -- test file for the Riemann Zeta function -Copyright 2003, 2004 Free Software Foundation. +Copyright 2003, 2004, 2005 Free Software Foundation. Contributed by Jean-Luc Re'my and the Spaces project, INRIA Lorraine. This file is part of the MPFR Library. @@ -215,7 +215,7 @@ main (int argc, char *argv[]) mpfr_init2 (s, prec); mpfr_init2 (z, prec); mpfr_set_str (s, argv[1], 10, GMP_RNDN); - rnd_mode = atoi(argv[3]); + rnd_mode = (mp_rnd_t) atoi(argv[3]); mpfr_zeta (z, s, rnd_mode); mpfr_out_str (stdout, 10, 0, z, GMP_RNDN); |