summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Ryde <user42@zip.com.au>2002-04-09 02:10:20 +0200
committerKevin Ryde <user42@zip.com.au>2002-04-09 02:10:20 +0200
commitaf5c898efe6d9c24434cb196b6d53dc52611aac7 (patch)
treeb0bb85f345ef57985def7f699b594fdb783250df
parent6478d5b3d18cef5a016730d9921f0d2d970ef600 (diff)
downloadgmp-af5c898efe6d9c24434cb196b6d53dc52611aac7.tar.gz
* mpfr/*: Update to 2.0.1.
-rw-r--r--mpfr/COPYING664
-rw-r--r--mpfr/COPYING.LIB504
-rw-r--r--mpfr/Makefile.am3
-rw-r--r--mpfr/Makefile.in93
-rw-r--r--mpfr/README4
-rw-r--r--mpfr/TODO28
-rw-r--r--mpfr/acos.c4
-rw-r--r--mpfr/acosh.c4
-rw-r--r--mpfr/add.c4
-rw-r--r--mpfr/add1.c4
-rw-r--r--mpfr/add_one_ulp.c4
-rw-r--r--mpfr/add_ui.c4
-rw-r--r--mpfr/agm.c26
-rw-r--r--mpfr/asin.c9
-rw-r--r--mpfr/asinh.c4
-rw-r--r--mpfr/atan.c4
-rw-r--r--mpfr/atanh.c4
-rw-r--r--mpfr/clear.c4
-rw-r--r--mpfr/cmp.c4
-rw-r--r--mpfr/cmp2.c4
-rw-r--r--mpfr/cmp_abs.c4
-rw-r--r--mpfr/cmp_ui.c11
-rw-r--r--mpfr/const_euler.c4
-rw-r--r--mpfr/const_log2.c4
-rw-r--r--mpfr/const_pi.c4
-rw-r--r--mpfr/copysign.c4
-rw-r--r--mpfr/cos.c4
-rw-r--r--mpfr/cosh.c4
-rw-r--r--mpfr/dim.c4
-rw-r--r--mpfr/div.c4
-rw-r--r--mpfr/div_2exp.c4
-rw-r--r--mpfr/div_2si.c4
-rw-r--r--mpfr/div_2ui.c4
-rw-r--r--mpfr/div_ui.c4
-rw-r--r--mpfr/dump.c4
-rw-r--r--mpfr/eq.c4
-rw-r--r--mpfr/exceptions.c4
-rw-r--r--mpfr/exp.c6
-rw-r--r--mpfr/exp2.c42
-rw-r--r--mpfr/exp3.c4
-rw-r--r--mpfr/exp_2.c21
-rw-r--r--mpfr/expm1.c4
-rw-r--r--mpfr/extract.c20
-rw-r--r--mpfr/factorial.c4
-rw-r--r--mpfr/fma.c104
-rw-r--r--mpfr/generic.c4
-rw-r--r--mpfr/get_str.c6
-rw-r--r--mpfr/gmp_op.c4
-rw-r--r--mpfr/hypot.c4
-rw-r--r--mpfr/i_ceil_exp2.c42
-rw-r--r--mpfr/i_ceil_log2.c40
-rw-r--r--mpfr/i_floor_log2.c35
-rw-r--r--mpfr/init.c4
-rw-r--r--mpfr/init2.c4
-rw-r--r--mpfr/inp_str.c4
-rw-r--r--mpfr/isinf.c4
-rw-r--r--mpfr/isinteger.c4
-rw-r--r--mpfr/isnan.c4
-rw-r--r--mpfr/isnum.c4
-rw-r--r--mpfr/log.c10
-rw-r--r--mpfr/log10.c10
-rw-r--r--mpfr/log1p.c4
-rw-r--r--mpfr/log2.c8
-rw-r--r--mpfr/minmax.c4
-rw-r--r--mpfr/mpf2mpfr.h6
-rw-r--r--mpfr/mpfr-impl.h11
-rw-r--r--mpfr/mpfr-test.h70
-rw-r--r--mpfr/mpfr.h9
-rw-r--r--mpfr/mpfr.texi100
-rw-r--r--mpfr/mpz_set_fr.c71
-rw-r--r--mpfr/mul.c4
-rw-r--r--mpfr/mul_2exp.c4
-rw-r--r--mpfr/mul_2si.c4
-rw-r--r--mpfr/mul_2ui.c4
-rw-r--r--mpfr/mul_ui.c4
-rw-r--r--mpfr/neg.c4
-rw-r--r--mpfr/out_str.c4
-rw-r--r--mpfr/pow.c4
-rw-r--r--mpfr/pow_si.c4
-rw-r--r--mpfr/pow_ui.c4
-rw-r--r--mpfr/print_raw.c4
-rw-r--r--mpfr/print_rnd_mode.c10
-rw-r--r--mpfr/random.c4
-rw-r--r--mpfr/random2.c4
-rw-r--r--mpfr/reldiff.c4
-rw-r--r--mpfr/rint.c4
-rw-r--r--mpfr/rnd_mode.c105
-rw-r--r--mpfr/round_prec.c4
-rw-r--r--mpfr/save_expo.c4
-rw-r--r--mpfr/set.c4
-rw-r--r--mpfr/set_d.c195
-rw-r--r--mpfr/set_dfl_prec.c4
-rw-r--r--mpfr/set_f.c4
-rw-r--r--mpfr/set_prc_raw.c4
-rw-r--r--mpfr/set_prec.c4
-rw-r--r--mpfr/set_q.c9
-rw-r--r--mpfr/set_rnd.c4
-rw-r--r--mpfr/set_si.c12
-rw-r--r--mpfr/set_str.c4
-rw-r--r--mpfr/set_str_raw.c15
-rw-r--r--mpfr/set_ui.c4
-rw-r--r--mpfr/set_z.c4
-rw-r--r--mpfr/sin.c4
-rw-r--r--mpfr/sin_cos.c4
-rw-r--r--mpfr/sinh.c4
-rw-r--r--mpfr/sqrt.c18
-rw-r--r--mpfr/sqrt_ui.c4
-rw-r--r--mpfr/sub.c4
-rw-r--r--mpfr/sub1.c4
-rw-r--r--mpfr/sub_one_ulp.c4
-rw-r--r--mpfr/sub_ui.c4
-rw-r--r--mpfr/swap.c4
-rw-r--r--mpfr/tan.c4
-rw-r--r--mpfr/tanh.c4
-rw-r--r--mpfr/tests/Makefile.am2
-rw-r--r--mpfr/tests/Makefile.in4
-rw-r--r--mpfr/tests/reuse.c243
-rw-r--r--mpfr/tests/tabs.c77
-rw-r--r--mpfr/tests/tacos.c4
-rw-r--r--mpfr/tests/tacosh.c4
-rw-r--r--mpfr/tests/tadd.c116
-rw-r--r--mpfr/tests/tadd_ui.c56
-rw-r--r--mpfr/tests/tagm.c31
-rw-r--r--mpfr/tests/tasin.c19
-rw-r--r--mpfr/tests/tasinh.c4
-rw-r--r--mpfr/tests/tatan.c4
-rw-r--r--mpfr/tests/tatanh.c4
-rw-r--r--mpfr/tests/tcan_round.c4
-rw-r--r--mpfr/tests/tcmp.c27
-rw-r--r--mpfr/tests/tcmp2.c17
-rw-r--r--mpfr/tests/tcmp_ui.c18
-rw-r--r--mpfr/tests/tconst_euler.c4
-rw-r--r--mpfr/tests/tconst_log2.c10
-rw-r--r--mpfr/tests/tconst_pi.c6
-rw-r--r--mpfr/tests/tcos.c17
-rw-r--r--mpfr/tests/tcosh.c4
-rw-r--r--mpfr/tests/tdiv.c51
-rw-r--r--mpfr/tests/tdiv_ui.c39
-rw-r--r--mpfr/tests/tdump.c5
-rw-r--r--mpfr/tests/teq.c4
-rw-r--r--mpfr/tests/texceptions.c4
-rw-r--r--mpfr/tests/texp.c36
-rw-r--r--mpfr/tests/texp2.c21
-rw-r--r--mpfr/tests/texpm1.c4
-rw-r--r--mpfr/tests/tfactorial.c4
-rw-r--r--mpfr/tests/tfma.c24
-rw-r--r--mpfr/tests/tgeneric.c4
-rw-r--r--mpfr/tests/tget_d.c84
-rw-r--r--mpfr/tests/tget_str.c15
-rw-r--r--mpfr/tests/thyperbolic.c4
-rw-r--r--mpfr/tests/thypot.c4
-rw-r--r--mpfr/tests/tisnan.c4
-rw-r--r--mpfr/tests/tlog.c43
-rw-r--r--mpfr/tests/tlog10.c26
-rw-r--r--mpfr/tests/tlog1p.c4
-rw-r--r--mpfr/tests/tlog2.c4
-rw-r--r--mpfr/tests/tmul.c69
-rw-r--r--mpfr/tests/tmul_2exp.c25
-rw-r--r--mpfr/tests/tmul_ui.c31
-rw-r--r--mpfr/tests/tout_str.c17
-rw-r--r--mpfr/tests/tpow.c32
-rw-r--r--mpfr/tests/tpow3.c4
-rw-r--r--mpfr/tests/trandom.c14
-rw-r--r--mpfr/tests/trint.c7
-rw-r--r--mpfr/tests/tround_prec.c12
-rw-r--r--mpfr/tests/tset.c7
-rw-r--r--mpfr/tests/tset_d.c78
-rw-r--r--mpfr/tests/tset_f.c12
-rw-r--r--mpfr/tests/tset_q.c25
-rw-r--r--mpfr/tests/tset_si.c36
-rw-r--r--mpfr/tests/tset_str.c22
-rw-r--r--mpfr/tests/tset_z.c13
-rw-r--r--mpfr/tests/tsin.c30
-rw-r--r--mpfr/tests/tsinh.c4
-rw-r--r--mpfr/tests/tsqrt.c52
-rw-r--r--mpfr/tests/tsqrt_ui.c41
-rw-r--r--mpfr/tests/tsub.c12
-rw-r--r--mpfr/tests/tsub_ui.c50
-rw-r--r--mpfr/tests/tswap.c6
-rw-r--r--mpfr/tests/ttan.c55
-rw-r--r--mpfr/tests/ttanh.c4
-rw-r--r--mpfr/tests/ttrunc.c16
-rw-r--r--mpfr/tests/tui_div.c50
-rw-r--r--mpfr/tests/tui_pow.c4
-rw-r--r--mpfr/tests/tui_sub.c43
-rw-r--r--mpfr/ui_div.c4
-rw-r--r--mpfr/ui_pow.c4
-rw-r--r--mpfr/ui_pow_ui.c4
-rw-r--r--mpfr/ui_sub.c4
-rw-r--r--mpfr/urandomb.c4
190 files changed, 1981 insertions, 2506 deletions
diff --git a/mpfr/COPYING b/mpfr/COPYING
index 5b6e7c66c..b1e3f5a26 100644
--- a/mpfr/COPYING
+++ b/mpfr/COPYING
@@ -1,221 +1,397 @@
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
-modification follow.
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
- GNU GENERAL PUBLIC LICENSE
+ GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
- a) You must cause the modified files to carry prominent notices
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
+identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
+on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
+entire whole, and thus to each and every part regardless of who wrote
+it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
-collective works based on the Program.
+collective works based on the Library.
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
+distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
+the Library or works based on it.
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
+You are not responsible for enforcing compliance by third parties with
this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
+
+ 11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
+refrain entirely from distribution of the Library.
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
+integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
@@ -225,116 +401,104 @@ impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
+
+ 12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
NO WARRANTY
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
END OF TERMS AND CONDITIONS
- How to Apply These Terms to Your New Programs
+ How to Apply These Terms to Your New Libraries
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
- <one line to give the program's name and a brief idea of what it does.>
+ <one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
- This program is distributed in the hope that it will be useful,
+ This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
Also add information on how to contact you by electronic and paper mail.
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) year name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
+school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
- <signature of Ty Coon>, 1 April 1989
+ <signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
+That's all there is to it!
+
+
diff --git a/mpfr/COPYING.LIB b/mpfr/COPYING.LIB
deleted file mode 100644
index b1e3f5a26..000000000
--- a/mpfr/COPYING.LIB
+++ /dev/null
@@ -1,504 +0,0 @@
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the Lesser GPL. It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.]
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
- This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it. You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations below.
-
- When we speak of free software, we are referring to freedom of use,
-not price. Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
- To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights. These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
- For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you. You must make sure that they, too, receive or can get the source
-code. If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it. And you must show them these terms so they know their rights.
-
- We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
- To protect each distributor, we want to make it very clear that
-there is no warranty for the free library. Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-
- Finally, software patents pose a constant threat to the existence of
-any free program. We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder. Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
- Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License. This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License. We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
- When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library. The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom. The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
- We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License. It also provides other free software developers Less
-of an advantage over competing non-free programs. These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries. However, the Lesser license provides advantages in certain
-special circumstances.
-
- For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it becomes
-a de-facto standard. To achieve this, non-free programs must be
-allowed to use the library. A more frequent case is that a free
-library does the same job as widely used non-free libraries. In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
- In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software. For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
- Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
- The precise terms and conditions for copying, distribution and
-modification follow. Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library". The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-
- GNU LESSER GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
- A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
- The "Library", below, refers to any such software library or work
-which has been distributed under these terms. A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language. (Hereinafter, translation is
-included without limitation in the term "modification".)
-
- "Source code" for a work means the preferred form of the work for
-making modifications to it. For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control compilation
-and installation of the library.
-
- Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it). Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
- 1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
- You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-
- 2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) The modified work must itself be a software library.
-
- b) You must cause the files modified to carry prominent notices
- stating that you changed the files and the date of any change.
-
- c) You must cause the whole of the work to be licensed at no
- charge to all third parties under the terms of this License.
-
- d) If a facility in the modified Library refers to a function or a
- table of data to be supplied by an application program that uses
- the facility, other than as an argument passed when the facility
- is invoked, then you must make a good faith effort to ensure that,
- in the event an application does not supply such function or
- table, the facility still operates, and performs whatever part of
- its purpose remains meaningful.
-
- (For example, a function in a library to compute square roots has
- a purpose that is entirely well-defined independent of the
- application. Therefore, Subsection 2d requires that any
- application-supplied function or table used by this function must
- be optional: if the application does not supply it, the square
- root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library. To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License. (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.) Do not make any other change in
-these notices.
-
- Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
- This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
- 4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
- If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library". Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
- However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library". The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
- When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library. The
-threshold for this to be true is not precisely defined by law.
-
- If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work. (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
- Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-
- 6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
- You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License. You must supply a copy of this License. If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License. Also, you must do one
-of these things:
-
- a) Accompany the work with the complete corresponding
- machine-readable source code for the Library including whatever
- changes were used in the work (which must be distributed under
- Sections 1 and 2 above); and, if the work is an executable linked
- with the Library, with the complete machine-readable "work that
- uses the Library", as object code and/or source code, so that the
- user can modify the Library and then relink to produce a modified
- executable containing the modified Library. (It is understood
- that the user who changes the contents of definitions files in the
- Library will not necessarily be able to recompile the application
- to use the modified definitions.)
-
- b) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (1) uses at run time a
- copy of the library already present on the user's computer system,
- rather than copying library functions into the executable, and (2)
- will operate properly with a modified version of the library, if
- the user installs one, as long as the modified version is
- interface-compatible with the version that the work was made with.
-
- c) Accompany the work with a written offer, valid for at
- least three years, to give the same user the materials
- specified in Subsection 6a, above, for a charge no more
- than the cost of performing this distribution.
-
- d) If distribution of the work is made by offering access to copy
- from a designated place, offer equivalent access to copy the above
- specified materials from the same place.
-
- e) Verify that the user has already received a copy of these
- materials or that you have already sent this user a copy.
-
- For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it. However, as a special exception,
-the materials to be distributed need not include anything that is
-normally distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
- It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system. Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-
- 7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
- a) Accompany the combined library with a copy of the same work
- based on the Library, uncombined with any other library
- facilities. This must be distributed under the terms of the
- Sections above.
-
- b) Give prominent notice with the combined library of the fact
- that part of it is a work based on the Library, and explaining
- where to find the accompanying uncombined form of the same work.
-
- 8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License. Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License. However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
- 9. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Library or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
- 10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties with
-this License.
-
- 11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all. For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under any
-particular circumstance, the balance of the section is intended to apply,
-and the section as a whole is intended to apply in other circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License may add
-an explicit geographical distribution limitation excluding those countries,
-so that distribution is permitted only in or among countries not thus
-excluded. In such case, this License incorporates the limitation as if
-written in the body of this License.
-
- 13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation. If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-
- 14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission. For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this. Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
- NO WARRANTY
-
- 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Libraries
-
- If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change. You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms of the
-ordinary General Public License).
-
- To apply these terms, attach the following notices to the library. It is
-safest to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
-
- <one line to give the library's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the library, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the
- library `Frob' (a library for tweaking knobs) written by James Random Hacker.
-
- <signature of Ty Coon>, 1 April 1990
- Ty Coon, President of Vice
-
-That's all there is to it!
-
-
diff --git a/mpfr/Makefile.am b/mpfr/Makefile.am
index 82204beb3..20baef4d6 100644
--- a/mpfr/Makefile.am
+++ b/mpfr/Makefile.am
@@ -28,6 +28,7 @@ AUTOMAKE_OPTIONS = gnu no-dependencies $(top_builddir)/ansi2knr
SUBDIRS = tests
INCLUDES = -I$(top_srcdir)
+CFLAGS = @CFLAGS@ $(MPFR_CFLAGS)
if WANT_MPFR
lib_LIBRARIES = libmpfr.a
@@ -42,6 +43,6 @@ TEXINFO_TEX = ../texinfo.tex
# Override automake default AR=ar with the value from GMP_PROG_AR.
AR = @AR@
-libmpfr_a_SOURCES= cputime.h mpfr.h mpfr-impl.h exceptions.c save_expo.c extract.c i_ceil_exp2.c i_ceil_log2.c i_floor_log2.c add.c add1.c add_one_ulp.c add_ui.c agm.c clear.c cmp.c cmp_abs.c cmp_ui.c div_2exp.c div_2si.c div_2ui.c div.c div_ui.c dump.c eq.c exp2.c exp3.c exp.c get_str.c init.c inp_str.c isinteger.c isinf.c isnan.c isnum.c const_log2.c log.c mul_2exp.c mul_2si.c mul_2ui.c mul.c mul_ui.c neg.c out_str.c const_pi.c pow.c pow_si.c pow_ui.c print_raw.c print_rnd_mode.c random2.c random.c reldiff.c rnd_mode.c round_prec.c set.c set_d.c set_dfl_prec.c set_rnd.c set_f.c set_prc_raw.c set_prec.c set_q.c set_si.c set_str.c set_str_raw.c set_ui.c set_z.c sqrt.c sqrt_ui.c sub.c sub1.c sub_one_ulp.c sub_ui.c rint.c ui_div.c ui_sub.c urandomb.c mpz_set_fr.c swap.c factorial.c cosh.c sinh.c tanh.c acosh.c asinh.c atanh.c atan.c cmp2.c exp_2.c asin.c const_euler.c cos.c sin.c sin_cos.c tan.c fma.c hypot.c log1p.c expm1.c log2.c log10.c ui_pow.c ui_pow_ui.c minmax.c dim.c copysign.c gmp_op.c init2.c acos.c
+libmpfr_a_SOURCES= cputime.h mpfr.h mpfr-impl.h exceptions.c save_expo.c extract.c uceil_exp2.c uceil_log2.c ufloor_log2.c add.c add1.c add_one_ulp.c add_ui.c agm.c clear.c cmp.c cmp_abs.c cmp_ui.c div_2exp.c div_2si.c div_2ui.c div.c div_ui.c dump.c eq.c exp2.c exp3.c exp.c get_d.c get_str.c init.c inp_str.c isinteger.c isinf.c isnan.c isnum.c const_log2.c log.c mul_2exp.c mul_2si.c mul_2ui.c mul.c mul_ui.c neg.c out_str.c const_pi.c pow.c pow_si.c pow_ui.c print_raw.c print_rnd_mode.c random2.c random.c reldiff.c rnd_mode.c round_prec.c set.c set_d.c set_dfl_prec.c set_rnd.c set_f.c set_prc_raw.c set_prec.c set_q.c set_si.c set_str.c set_str_raw.c set_ui.c set_z.c sqrt.c sqrt_ui.c sub.c sub1.c sub_one_ulp.c sub_ui.c rint.c ui_div.c ui_sub.c urandomb.c get_z_exp.c swap.c factorial.c cosh.c sinh.c tanh.c acosh.c asinh.c atanh.c atan.c cmp2.c exp_2.c asin.c const_euler.c cos.c sin.c tan.c fma.c hypot.c log1p.c expm1.c log2.c log10.c ui_pow.c ui_pow_ui.c minmax.c dim.c copysign.c gmp_op.c init2.c acos.c sin_cos.c set_nan.c set_inf.c
EXTRA_DIST = generic.c mpfr-test.h mpf2mpfr.h
diff --git a/mpfr/Makefile.in b/mpfr/Makefile.in
index 23240e704..9c27f173e 100644
--- a/mpfr/Makefile.in
+++ b/mpfr/Makefile.in
@@ -86,7 +86,6 @@ BITS_PER_MP_LIMB = @BITS_PER_MP_LIMB@
CALLING_CONVENTIONS_OBJS = @CALLING_CONVENTIONS_OBJS@
CC = @CC@
CCAS = @CCAS@
-CFLAGS_IEEE_WITH_INEXACT = @CFLAGS_IEEE_WITH_INEXACT@
CPP = @CPP@
CXX = @CXX@
CXXCPP = @CXXCPP@
@@ -113,6 +112,7 @@ LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
M4 = @M4@
MAINT = @MAINT@
+MPFR_CFLAGS = @MPFR_CFLAGS@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
@@ -143,7 +143,7 @@ AUTOMAKE_OPTIONS = gnu no-dependencies $(top_builddir)/ansi2knr
SUBDIRS = tests
INCLUDES = -I$(top_srcdir)
-CFLAGS = @CFLAGS@ $(CFLAGS_IEEE_WITH_INEXACT)
+CFLAGS = @CFLAGS@ $(MPFR_CFLAGS)
@WANT_MPFR_TRUE@lib_LIBRARIES = libmpfr.a
@WANT_MPFR_TRUE@include_HEADERS = mpfr.h
@@ -153,7 +153,7 @@ CFLAGS = @CFLAGS@ $(CFLAGS_IEEE_WITH_INEXACT)
info_TEXINFOS = mpfr.texi
TEXINFO_TEX = ../texinfo.tex
-libmpfr_a_SOURCES = cputime.h mpfr.h mpfr-impl.h exceptions.c save_expo.c extract.c i_ceil_exp2.c i_ceil_log2.c i_floor_log2.c add.c add1.c add_one_ulp.c add_ui.c agm.c clear.c cmp.c cmp_abs.c cmp_ui.c div_2exp.c div_2si.c div_2ui.c div.c div_ui.c dump.c eq.c exp2.c exp3.c exp.c get_str.c init.c inp_str.c isinteger.c isinf.c isnan.c isnum.c const_log2.c log.c mul_2exp.c mul_2si.c mul_2ui.c mul.c mul_ui.c neg.c out_str.c const_pi.c pow.c pow_si.c pow_ui.c print_raw.c print_rnd_mode.c random2.c random.c reldiff.c rnd_mode.c round_prec.c set.c set_d.c set_dfl_prec.c set_rnd.c set_f.c set_prc_raw.c set_prec.c set_q.c set_si.c set_str.c set_str_raw.c set_ui.c set_z.c sqrt.c sqrt_ui.c sub.c sub1.c sub_one_ulp.c sub_ui.c rint.c ui_div.c ui_sub.c urandomb.c mpz_set_fr.c swap.c factorial.c cosh.c sinh.c tanh.c acosh.c asinh.c atanh.c atan.c cmp2.c exp_2.c asin.c const_euler.c cos.c sin.c sin_cos.c tan.c fma.c hypot.c log1p.c expm1.c log2.c log10.c ui_pow.c ui_pow_ui.c minmax.c dim.c copysign.c gmp_op.c init2.c acos.c
+libmpfr_a_SOURCES = cputime.h mpfr.h mpfr-impl.h exceptions.c save_expo.c extract.c uceil_exp2.c uceil_log2.c ufloor_log2.c add.c add1.c add_one_ulp.c add_ui.c agm.c clear.c cmp.c cmp_abs.c cmp_ui.c div_2exp.c div_2si.c div_2ui.c div.c div_ui.c dump.c eq.c exp2.c exp3.c exp.c get_d.c get_str.c init.c inp_str.c isinteger.c isinf.c isnan.c isnum.c const_log2.c log.c mul_2exp.c mul_2si.c mul_2ui.c mul.c mul_ui.c neg.c out_str.c const_pi.c pow.c pow_si.c pow_ui.c print_raw.c print_rnd_mode.c random2.c random.c reldiff.c rnd_mode.c round_prec.c set.c set_d.c set_dfl_prec.c set_rnd.c set_f.c set_prc_raw.c set_prec.c set_q.c set_si.c set_str.c set_str_raw.c set_ui.c set_z.c sqrt.c sqrt_ui.c sub.c sub1.c sub_one_ulp.c sub_ui.c rint.c ui_div.c ui_sub.c urandomb.c get_z_exp.c swap.c factorial.c cosh.c sinh.c tanh.c acosh.c asinh.c atanh.c atan.c cmp2.c exp_2.c asin.c const_euler.c cos.c sin.c tan.c fma.c hypot.c log1p.c expm1.c log2.c log10.c ui_pow.c ui_pow_ui.c minmax.c dim.c copysign.c gmp_op.c init2.c acos.c sin_cos.c set_nan.c set_inf.c
EXTRA_DIST = generic.c mpfr-test.h mpf2mpfr.h
subdir = mpfr
@@ -165,15 +165,15 @@ LIBRARIES = $(lib_LIBRARIES)
libmpfr_a_AR = $(AR) cru
libmpfr_a_LIBADD =
am_libmpfr_a_OBJECTS = exceptions$U.$(OBJEXT) save_expo$U.$(OBJEXT) \
- extract$U.$(OBJEXT) i_ceil_exp2$U.$(OBJEXT) \
- i_ceil_log2$U.$(OBJEXT) i_floor_log2$U.$(OBJEXT) \
- add$U.$(OBJEXT) add1$U.$(OBJEXT) add_one_ulp$U.$(OBJEXT) \
- add_ui$U.$(OBJEXT) agm$U.$(OBJEXT) clear$U.$(OBJEXT) \
- cmp$U.$(OBJEXT) cmp_abs$U.$(OBJEXT) cmp_ui$U.$(OBJEXT) \
- div_2exp$U.$(OBJEXT) div_2si$U.$(OBJEXT) div_2ui$U.$(OBJEXT) \
- div$U.$(OBJEXT) div_ui$U.$(OBJEXT) dump$U.$(OBJEXT) \
- eq$U.$(OBJEXT) exp2$U.$(OBJEXT) exp3$U.$(OBJEXT) \
- exp$U.$(OBJEXT) get_str$U.$(OBJEXT) init$U.$(OBJEXT) \
+ extract$U.$(OBJEXT) uceil_exp2$U.$(OBJEXT) \
+ uceil_log2$U.$(OBJEXT) ufloor_log2$U.$(OBJEXT) add$U.$(OBJEXT) \
+ add1$U.$(OBJEXT) add_one_ulp$U.$(OBJEXT) add_ui$U.$(OBJEXT) \
+ agm$U.$(OBJEXT) clear$U.$(OBJEXT) cmp$U.$(OBJEXT) \
+ cmp_abs$U.$(OBJEXT) cmp_ui$U.$(OBJEXT) div_2exp$U.$(OBJEXT) \
+ div_2si$U.$(OBJEXT) div_2ui$U.$(OBJEXT) div$U.$(OBJEXT) \
+ div_ui$U.$(OBJEXT) dump$U.$(OBJEXT) eq$U.$(OBJEXT) \
+ exp2$U.$(OBJEXT) exp3$U.$(OBJEXT) exp$U.$(OBJEXT) \
+ get_d$U.$(OBJEXT) get_str$U.$(OBJEXT) init$U.$(OBJEXT) \
inp_str$U.$(OBJEXT) isinteger$U.$(OBJEXT) isinf$U.$(OBJEXT) \
isnan$U.$(OBJEXT) isnum$U.$(OBJEXT) const_log2$U.$(OBJEXT) \
log$U.$(OBJEXT) mul_2exp$U.$(OBJEXT) mul_2si$U.$(OBJEXT) \
@@ -190,17 +190,18 @@ am_libmpfr_a_OBJECTS = exceptions$U.$(OBJEXT) save_expo$U.$(OBJEXT) \
sqrt$U.$(OBJEXT) sqrt_ui$U.$(OBJEXT) sub$U.$(OBJEXT) \
sub1$U.$(OBJEXT) sub_one_ulp$U.$(OBJEXT) sub_ui$U.$(OBJEXT) \
rint$U.$(OBJEXT) ui_div$U.$(OBJEXT) ui_sub$U.$(OBJEXT) \
- urandomb$U.$(OBJEXT) mpz_set_fr$U.$(OBJEXT) swap$U.$(OBJEXT) \
+ urandomb$U.$(OBJEXT) get_z_exp$U.$(OBJEXT) swap$U.$(OBJEXT) \
factorial$U.$(OBJEXT) cosh$U.$(OBJEXT) sinh$U.$(OBJEXT) \
tanh$U.$(OBJEXT) acosh$U.$(OBJEXT) asinh$U.$(OBJEXT) \
atanh$U.$(OBJEXT) atan$U.$(OBJEXT) cmp2$U.$(OBJEXT) \
exp_2$U.$(OBJEXT) asin$U.$(OBJEXT) const_euler$U.$(OBJEXT) \
- cos$U.$(OBJEXT) sin$U.$(OBJEXT) sin_cos$U.$(OBJEXT) \
- tan$U.$(OBJEXT) fma$U.$(OBJEXT) hypot$U.$(OBJEXT) \
- log1p$U.$(OBJEXT) expm1$U.$(OBJEXT) log2$U.$(OBJEXT) \
- log10$U.$(OBJEXT) ui_pow$U.$(OBJEXT) ui_pow_ui$U.$(OBJEXT) \
- minmax$U.$(OBJEXT) dim$U.$(OBJEXT) copysign$U.$(OBJEXT) \
- gmp_op$U.$(OBJEXT) init2$U.$(OBJEXT) acos$U.$(OBJEXT)
+ cos$U.$(OBJEXT) sin$U.$(OBJEXT) tan$U.$(OBJEXT) fma$U.$(OBJEXT) \
+ hypot$U.$(OBJEXT) log1p$U.$(OBJEXT) expm1$U.$(OBJEXT) \
+ log2$U.$(OBJEXT) log10$U.$(OBJEXT) ui_pow$U.$(OBJEXT) \
+ ui_pow_ui$U.$(OBJEXT) minmax$U.$(OBJEXT) dim$U.$(OBJEXT) \
+ copysign$U.$(OBJEXT) gmp_op$U.$(OBJEXT) init2$U.$(OBJEXT) \
+ acos$U.$(OBJEXT) sin_cos$U.$(OBJEXT) set_nan$U.$(OBJEXT) \
+ set_inf$U.$(OBJEXT)
libmpfr_a_OBJECTS = $(am_libmpfr_a_OBJECTS)
DEFS = @DEFS@
@@ -382,18 +383,16 @@ factorial_.c: factorial.c $(ANSI2KNR)
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/factorial.c; then echo $(srcdir)/factorial.c; else echo factorial.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > factorial_.c || rm -f factorial_.c
fma_.c: fma.c $(ANSI2KNR)
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/fma.c; then echo $(srcdir)/fma.c; else echo fma.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > fma_.c || rm -f fma_.c
+get_d_.c: get_d.c $(ANSI2KNR)
+ $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/get_d.c; then echo $(srcdir)/get_d.c; else echo get_d.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > get_d_.c || rm -f get_d_.c
get_str_.c: get_str.c $(ANSI2KNR)
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/get_str.c; then echo $(srcdir)/get_str.c; else echo get_str.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > get_str_.c || rm -f get_str_.c
+get_z_exp_.c: get_z_exp.c $(ANSI2KNR)
+ $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/get_z_exp.c; then echo $(srcdir)/get_z_exp.c; else echo get_z_exp.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > get_z_exp_.c || rm -f get_z_exp_.c
gmp_op_.c: gmp_op.c $(ANSI2KNR)
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/gmp_op.c; then echo $(srcdir)/gmp_op.c; else echo gmp_op.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > gmp_op_.c || rm -f gmp_op_.c
hypot_.c: hypot.c $(ANSI2KNR)
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/hypot.c; then echo $(srcdir)/hypot.c; else echo hypot.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > hypot_.c || rm -f hypot_.c
-i_ceil_exp2_.c: i_ceil_exp2.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/i_ceil_exp2.c; then echo $(srcdir)/i_ceil_exp2.c; else echo i_ceil_exp2.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > i_ceil_exp2_.c || rm -f i_ceil_exp2_.c
-i_ceil_log2_.c: i_ceil_log2.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/i_ceil_log2.c; then echo $(srcdir)/i_ceil_log2.c; else echo i_ceil_log2.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > i_ceil_log2_.c || rm -f i_ceil_log2_.c
-i_floor_log2_.c: i_floor_log2.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/i_floor_log2.c; then echo $(srcdir)/i_floor_log2.c; else echo i_floor_log2.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > i_floor_log2_.c || rm -f i_floor_log2_.c
init_.c: init.c $(ANSI2KNR)
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/init.c; then echo $(srcdir)/init.c; else echo init.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > init_.c || rm -f init_.c
init2_.c: init2.c $(ANSI2KNR)
@@ -418,8 +417,6 @@ log2_.c: log2.c $(ANSI2KNR)
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/log2.c; then echo $(srcdir)/log2.c; else echo log2.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > log2_.c || rm -f log2_.c
minmax_.c: minmax.c $(ANSI2KNR)
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/minmax.c; then echo $(srcdir)/minmax.c; else echo minmax.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > minmax_.c || rm -f minmax_.c
-mpz_set_fr_.c: mpz_set_fr.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/mpz_set_fr.c; then echo $(srcdir)/mpz_set_fr.c; else echo mpz_set_fr.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > mpz_set_fr_.c || rm -f mpz_set_fr_.c
mul_.c: mul.c $(ANSI2KNR)
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/mul.c; then echo $(srcdir)/mul.c; else echo mul.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > mul_.c || rm -f mul_.c
mul_2exp_.c: mul_2exp.c $(ANSI2KNR)
@@ -466,6 +463,10 @@ set_dfl_prec_.c: set_dfl_prec.c $(ANSI2KNR)
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/set_dfl_prec.c; then echo $(srcdir)/set_dfl_prec.c; else echo set_dfl_prec.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > set_dfl_prec_.c || rm -f set_dfl_prec_.c
set_f_.c: set_f.c $(ANSI2KNR)
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/set_f.c; then echo $(srcdir)/set_f.c; else echo set_f.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > set_f_.c || rm -f set_f_.c
+set_inf_.c: set_inf.c $(ANSI2KNR)
+ $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/set_inf.c; then echo $(srcdir)/set_inf.c; else echo set_inf.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > set_inf_.c || rm -f set_inf_.c
+set_nan_.c: set_nan.c $(ANSI2KNR)
+ $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/set_nan.c; then echo $(srcdir)/set_nan.c; else echo set_nan.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > set_nan_.c || rm -f set_nan_.c
set_prc_raw_.c: set_prc_raw.c $(ANSI2KNR)
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/set_prc_raw.c; then echo $(srcdir)/set_prc_raw.c; else echo set_prc_raw.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > set_prc_raw_.c || rm -f set_prc_raw_.c
set_prec_.c: set_prec.c $(ANSI2KNR)
@@ -508,6 +509,12 @@ tan_.c: tan.c $(ANSI2KNR)
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/tan.c; then echo $(srcdir)/tan.c; else echo tan.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > tan_.c || rm -f tan_.c
tanh_.c: tanh.c $(ANSI2KNR)
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/tanh.c; then echo $(srcdir)/tanh.c; else echo tanh.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > tanh_.c || rm -f tanh_.c
+uceil_exp2_.c: uceil_exp2.c $(ANSI2KNR)
+ $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/uceil_exp2.c; then echo $(srcdir)/uceil_exp2.c; else echo uceil_exp2.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > uceil_exp2_.c || rm -f uceil_exp2_.c
+uceil_log2_.c: uceil_log2.c $(ANSI2KNR)
+ $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/uceil_log2.c; then echo $(srcdir)/uceil_log2.c; else echo uceil_log2.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > uceil_log2_.c || rm -f uceil_log2_.c
+ufloor_log2_.c: ufloor_log2.c $(ANSI2KNR)
+ $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/ufloor_log2.c; then echo $(srcdir)/ufloor_log2.c; else echo ufloor_log2.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > ufloor_log2_.c || rm -f ufloor_log2_.c
ui_div_.c: ui_div.c $(ANSI2KNR)
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/ui_div.c; then echo $(srcdir)/ui_div.c; else echo ui_div.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > ui_div_.c || rm -f ui_div_.c
ui_pow_.c: ui_pow.c $(ANSI2KNR)
@@ -534,17 +541,15 @@ dump_.$(OBJEXT) dump_.lo eq_.$(OBJEXT) eq_.lo exceptions_.$(OBJEXT) \
exceptions_.lo exp_.$(OBJEXT) exp_.lo exp2_.$(OBJEXT) exp2_.lo \
exp3_.$(OBJEXT) exp3_.lo exp_2_.$(OBJEXT) exp_2_.lo expm1_.$(OBJEXT) \
expm1_.lo extract_.$(OBJEXT) extract_.lo factorial_.$(OBJEXT) \
-factorial_.lo fma_.$(OBJEXT) fma_.lo get_str_.$(OBJEXT) get_str_.lo \
-gmp_op_.$(OBJEXT) gmp_op_.lo hypot_.$(OBJEXT) hypot_.lo \
-i_ceil_exp2_.$(OBJEXT) i_ceil_exp2_.lo i_ceil_log2_.$(OBJEXT) \
-i_ceil_log2_.lo i_floor_log2_.$(OBJEXT) i_floor_log2_.lo \
-init_.$(OBJEXT) init_.lo init2_.$(OBJEXT) init2_.lo inp_str_.$(OBJEXT) \
-inp_str_.lo isinf_.$(OBJEXT) isinf_.lo isinteger_.$(OBJEXT) \
-isinteger_.lo isnan_.$(OBJEXT) isnan_.lo isnum_.$(OBJEXT) isnum_.lo \
-log_.$(OBJEXT) log_.lo log10_.$(OBJEXT) log10_.lo log1p_.$(OBJEXT) \
-log1p_.lo log2_.$(OBJEXT) log2_.lo minmax_.$(OBJEXT) minmax_.lo \
-mpz_set_fr_.$(OBJEXT) mpz_set_fr_.lo mul_.$(OBJEXT) mul_.lo \
-mul_2exp_.$(OBJEXT) mul_2exp_.lo mul_2si_.$(OBJEXT) mul_2si_.lo \
+factorial_.lo fma_.$(OBJEXT) fma_.lo get_d_.$(OBJEXT) get_d_.lo \
+get_str_.$(OBJEXT) get_str_.lo get_z_exp_.$(OBJEXT) get_z_exp_.lo \
+gmp_op_.$(OBJEXT) gmp_op_.lo hypot_.$(OBJEXT) hypot_.lo init_.$(OBJEXT) \
+init_.lo init2_.$(OBJEXT) init2_.lo inp_str_.$(OBJEXT) inp_str_.lo \
+isinf_.$(OBJEXT) isinf_.lo isinteger_.$(OBJEXT) isinteger_.lo \
+isnan_.$(OBJEXT) isnan_.lo isnum_.$(OBJEXT) isnum_.lo log_.$(OBJEXT) \
+log_.lo log10_.$(OBJEXT) log10_.lo log1p_.$(OBJEXT) log1p_.lo \
+log2_.$(OBJEXT) log2_.lo minmax_.$(OBJEXT) minmax_.lo mul_.$(OBJEXT) \
+mul_.lo mul_2exp_.$(OBJEXT) mul_2exp_.lo mul_2si_.$(OBJEXT) mul_2si_.lo \
mul_2ui_.$(OBJEXT) mul_2ui_.lo mul_ui_.$(OBJEXT) mul_ui_.lo \
neg_.$(OBJEXT) neg_.lo out_str_.$(OBJEXT) out_str_.lo pow_.$(OBJEXT) \
pow_.lo pow_si_.$(OBJEXT) pow_si_.lo pow_ui_.$(OBJEXT) pow_ui_.lo \
@@ -554,7 +559,8 @@ random2_.lo reldiff_.$(OBJEXT) reldiff_.lo rint_.$(OBJEXT) rint_.lo \
rnd_mode_.$(OBJEXT) rnd_mode_.lo round_prec_.$(OBJEXT) round_prec_.lo \
save_expo_.$(OBJEXT) save_expo_.lo set_.$(OBJEXT) set_.lo \
set_d_.$(OBJEXT) set_d_.lo set_dfl_prec_.$(OBJEXT) set_dfl_prec_.lo \
-set_f_.$(OBJEXT) set_f_.lo set_prc_raw_.$(OBJEXT) set_prc_raw_.lo \
+set_f_.$(OBJEXT) set_f_.lo set_inf_.$(OBJEXT) set_inf_.lo \
+set_nan_.$(OBJEXT) set_nan_.lo set_prc_raw_.$(OBJEXT) set_prc_raw_.lo \
set_prec_.$(OBJEXT) set_prec_.lo set_q_.$(OBJEXT) set_q_.lo \
set_rnd_.$(OBJEXT) set_rnd_.lo set_si_.$(OBJEXT) set_si_.lo \
set_str_.$(OBJEXT) set_str_.lo set_str_raw_.$(OBJEXT) set_str_raw_.lo \
@@ -563,10 +569,11 @@ sin_.lo sin_cos_.$(OBJEXT) sin_cos_.lo sinh_.$(OBJEXT) sinh_.lo \
sqrt_.$(OBJEXT) sqrt_.lo sqrt_ui_.$(OBJEXT) sqrt_ui_.lo sub_.$(OBJEXT) \
sub_.lo sub1_.$(OBJEXT) sub1_.lo sub_one_ulp_.$(OBJEXT) sub_one_ulp_.lo \
sub_ui_.$(OBJEXT) sub_ui_.lo swap_.$(OBJEXT) swap_.lo tan_.$(OBJEXT) \
-tan_.lo tanh_.$(OBJEXT) tanh_.lo ui_div_.$(OBJEXT) ui_div_.lo \
-ui_pow_.$(OBJEXT) ui_pow_.lo ui_pow_ui_.$(OBJEXT) ui_pow_ui_.lo \
-ui_sub_.$(OBJEXT) ui_sub_.lo urandomb_.$(OBJEXT) urandomb_.lo : \
-$(ANSI2KNR)
+tan_.lo tanh_.$(OBJEXT) tanh_.lo uceil_exp2_.$(OBJEXT) uceil_exp2_.lo \
+uceil_log2_.$(OBJEXT) uceil_log2_.lo ufloor_log2_.$(OBJEXT) \
+ufloor_log2_.lo ui_div_.$(OBJEXT) ui_div_.lo ui_pow_.$(OBJEXT) \
+ui_pow_.lo ui_pow_ui_.$(OBJEXT) ui_pow_ui_.lo ui_sub_.$(OBJEXT) \
+ui_sub_.lo urandomb_.$(OBJEXT) urandomb_.lo : $(ANSI2KNR)
mpfr.info: mpfr.texi
mpfr.dvi: mpfr.texi
diff --git a/mpfr/README b/mpfr/README
index 9a2e15f62..895051e94 100644
--- a/mpfr/README
+++ b/mpfr/README
@@ -1,6 +1,5 @@
The MPFR distribution contains the following files:
-
AUTHORS - the authors of the library
BUGS - bugs in MPFR - please read this file!
COPYING - the license under which the MPFR library is distributed
@@ -9,7 +8,9 @@ INSTALL - how to install MPFR (see also mpfr.texi)
Makefile* - files for building the library
NEWS - new features with respect to previous versions
README - this file
+README.dev - notes for the MPFR developers
TODO - what remains to do (any help is welcome!)
+VERSION - version of MPFR (next release version if taken from CVS)
ac* - automatic configuration files
*.c - source files
config* - configuration files
@@ -23,5 +24,6 @@ mpfr.h - external header file for MPFR
mpfr-test.h - header file for test files
mpfr.info - info file for MPFR
mpfr.texi - texinfo documentation for MPFR
+prepare - configuration script for CVS users
tests/ - test directory
texinfo.tex - TeX macros to handle mpfr.texi
diff --git a/mpfr/TODO b/mpfr/TODO
index 9e7d35264..481a08c54 100644
--- a/mpfr/TODO
+++ b/mpfr/TODO
@@ -1,6 +1,5 @@
Documentation:
-- update AUTHORS
- add a description of the algorithms used + proof of correctness
Installation:
@@ -14,6 +13,8 @@ Installation:
New functions to implement:
- those from LIA: missing secant, cosecant, cotangent (trigo/hyperbolic)
+- nextafter/nextforward : X + epsilon if X < Y, X - epsilon if X > Y
+- nextabove/nextbelow ?
Rounding:
@@ -21,16 +22,8 @@ Efficiency:
Miscellaneous:
-- initialize variables to signalling NaN (TG)
-
-- change Library GPL to Lesser GPL, and mention INRIA and/or SPACES
-
- rename mpf2mpfr.h to gmp-mpf2mpfr.h?
-- detect overflow/underflow in exponent (from Ben Hinkle <bhinkle4@juno.com>)
-
-- specify exponent size (suggestion from Ben Hinkle <bhinkle4@juno.com>)
-
- add mpfr_get_ld for 'long double' [asked by J-C Fauge`re] ?
(exists since K&R, but has not necessarily a greater precision than double)
cf http://anubis.dkuug.dk/jtc1/sc22/wg14/www/docs/n869/
@@ -54,16 +47,15 @@ i.e.0.10101011100001010011001101100101110011101110010001011000000000000000000000
to generate a NaN (for example under freebsd by default,
invalid, zerodivide and overflow generate exceptions)
-- detect overflows/underflows in addition/multiplication of ordinary numbers
- (PUTOT Sylvie <sputot@aigle.saclay.cea.fr>, Tue, 20 Mar 2001)
-
-- check correctness of +/-0 - +/-0 with different rounding modes.
-
-- rename mpz_set_fr to mpfr_get_mantissa_exp.
- (Kevin Ryde <user42@zip.com.au>, 22 Jan 2002)
- (Vincent Lefevre, 03 Feb 2002)
-
- rewrite mpfr_get_str and mpfr_set_str to use mpn_get_str and mpn_set_str.
(Torbjorn Granlund <tege@swox.com>, 30 Jan 2002)
- mpfr_pow isn't completely specified (concerning signed zeros).
+
+- use AC_CHECK_FUNCS for __setfpucw rather than grepping a header file.
+ (Kevin Ryde, 05 Mar 2002)
+
+- rename mpfr_isinteger to mpfr_integer_p.
+ (Kevin Ryde, 05 Mar 2002)
+
+- update mpfr_get_d3 to support the denormalized numbers.
diff --git a/mpfr/acos.c b/mpfr/acos.c
index 889c525c2..8d19df9ac 100644
--- a/mpfr/acos.c
+++ b/mpfr/acos.c
@@ -1,6 +1,6 @@
/* mpfr_acos -- arc-cosinus of a floating-point number
-Copyright (C) 2001, 2002 Free Software Foundation.
+Copyright 2001 Free Software Foundation.
This file is part of the MPFR Library, and was contributed by Mathieu Dutour.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/acosh.c b/mpfr/acosh.c
index 9a73d158e..969f6671f 100644
--- a/mpfr/acosh.c
+++ b/mpfr/acosh.c
@@ -1,6 +1,6 @@
/* mpfr_acosh -- Inverse Hyperbolic Cosine of Unsigned Integer Number
-Copyright (C) 2001-2002 Free Software Foundation.
+Copyright 2001, 2002 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/add.c b/mpfr/add.c
index aa91104e0..c4417d81c 100644
--- a/mpfr/add.c
+++ b/mpfr/add.c
@@ -1,6 +1,6 @@
/* mpfr_add -- add two floating-point numbers
-Copyright (C) 1999-2001 Free Software Foundation.
+Copyright 1999, 2000, 2001 Free Software Foundation.
Contributed by the Spaces project, INRIA Lorraine.
This file is part of the MPFR Library.
@@ -16,7 +16,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/add1.c b/mpfr/add1.c
index 09a41a032..008cc4d9b 100644
--- a/mpfr/add1.c
+++ b/mpfr/add1.c
@@ -1,6 +1,6 @@
/* mpfr_add1 -- internal function to perform a "real" addition
-Copyright (C) 1999-2001 Free Software Foundation.
+Copyright 1999, 2000, 2001 Free Software Foundation.
Contributed by the Spaces project, INRIA Lorraine.
This file is part of the MPFR Library.
@@ -16,7 +16,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/add_one_ulp.c b/mpfr/add_one_ulp.c
index a889ea226..8b83bdf7a 100644
--- a/mpfr/add_one_ulp.c
+++ b/mpfr/add_one_ulp.c
@@ -1,6 +1,6 @@
/* mpfr_add_one_ulp -- add one unit in last place
-Copyright (C) 1999, 2001 Free Software Foundation, Inc.
+Copyright 1999, 2001 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/add_ui.c b/mpfr/add_ui.c
index fb9526034..2b7fb46e4 100644
--- a/mpfr/add_ui.c
+++ b/mpfr/add_ui.c
@@ -1,6 +1,6 @@
/* mpfr_add_ui -- add a floating-point number with a machine integer
-Copyright (C) 2000-2002 Free Software Foundation.
+Copyright 2000, 2001, 2002 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/agm.c b/mpfr/agm.c
index 12638c500..5e0ade76a 100644
--- a/mpfr/agm.c
+++ b/mpfr/agm.c
@@ -1,6 +1,6 @@
/* mpfr_agm -- arithmetic-geometric mean of two floating-point numbers
-Copyright (C) 1999-2002 Free Software Foundation.
+Copyright 1999, 2000, 2001, 2002 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -32,9 +32,7 @@ mpfr_agm (mpfr_ptr r, mpfr_srcptr op2, mpfr_srcptr op1, mp_rnd_t rnd_mode)
double uo, vo;
mp_limb_t *up, *vp, *tmpp, *tmpup, *tmpvp, *ap, *bp;
mpfr_t u, v, tmp, tmpu, tmpv, a, b;
- TMP_DECL(marker1);
- {
- TMP_DECL(marker2);
+ TMP_DECL(marker);
/* If a or b is NaN, the result is NaN */
if (MPFR_IS_NAN(op1) || MPFR_IS_NAN(op2))
@@ -78,11 +76,10 @@ mpfr_agm (mpfr_ptr r, mpfr_srcptr op2, mpfr_srcptr op1, mp_rnd_t rnd_mode)
/* Initialisations */
go_on=1;
- TMP_MARK(marker1);
+ TMP_MARK(marker);
s=(p-1)/BITS_PER_MP_LIMB+1;
MPFR_INIT(ap, a, p, s);
MPFR_INIT(bp, b, p, s);
- TMP_MARK(marker2);
MPFR_INIT(up, u, p, s);
MPFR_INIT(vp, v, p, s);
MPFR_INIT(tmpup, tmpu, p, s);
@@ -100,6 +97,7 @@ mpfr_agm (mpfr_ptr r, mpfr_srcptr op2, mpfr_srcptr op1, mp_rnd_t rnd_mode)
else if (compare == 0)
{
mpfr_set (r, op1, rnd_mode);
+ TMP_FREE(marker);
return;
}
else
@@ -108,12 +106,11 @@ mpfr_agm (mpfr_ptr r, mpfr_srcptr op2, mpfr_srcptr op1, mp_rnd_t rnd_mode)
mpfr_set (a,op1,GMP_RNDN);
}
- vo=mpfr_get_d(b);
- uo=mpfr_get_d(a);
+ vo = mpfr_get_d1 (b);
+ uo = mpfr_get_d1 (a);
mpfr_set(u,a,GMP_RNDN);
mpfr_set(v,b,GMP_RNDN);
-
/* Main loop */
@@ -151,8 +148,6 @@ mpfr_agm (mpfr_ptr r, mpfr_srcptr op2, mpfr_srcptr op1, mp_rnd_t rnd_mode)
else {
go_on=1;
p+=5;
- TMP_FREE(marker2);
- TMP_MARK(marker2);
s=(p-1)/BITS_PER_MP_LIMB+1;
MPFR_INIT(up, u, p, s);
MPFR_INIT(vp, v, p, s);
@@ -167,11 +162,10 @@ mpfr_agm (mpfr_ptr r, mpfr_srcptr op2, mpfr_srcptr op1, mp_rnd_t rnd_mode)
/* Setting of the result */
- mpfr_set(r,v,rnd_mode);
- }
+ mpfr_set(r,v,rnd_mode);
/* Let's clean */
- TMP_FREE(marker1);
-
+ TMP_FREE(marker);
+
return ;
}
diff --git a/mpfr/asin.c b/mpfr/asin.c
index 95fd59a1c..95e894d84 100644
--- a/mpfr/asin.c
+++ b/mpfr/asin.c
@@ -1,6 +1,6 @@
/* mpfr_asin -- arc-sinus of a floating-point number
-Copyright (C) 2001 Free Software Foundation.
+Copyright 2001 Free Software Foundation.
This file is part of the MPFR Library, and was contributed by Mathieu Dutour.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -61,7 +61,7 @@ mpfr_asin (mpfr_ptr asin, mpfr_srcptr x, mp_rnd_t rnd_mode)
if (compared > 0) /* asin(x) = NaN for |x| > 1 */
{
MPFR_SET_NAN(asin);
- mpfr_clear(xp);
+ mpfr_clear (xp);
MPFR_RET_NAN;
}
@@ -76,9 +76,10 @@ mpfr_asin (mpfr_ptr asin, mpfr_srcptr x, mp_rnd_t rnd_mode)
else if (rnd_mode == GMP_RNDD)
rnd_mode = GMP_RNDU;
mpfr_const_pi (asin, rnd_mode);
+ mpfr_neg (asin, asin, rnd_mode);
}
MPFR_EXP(asin)--;
- mpfr_clear(xp);
+ mpfr_clear (xp);
return 1; /* inexact */
}
diff --git a/mpfr/asinh.c b/mpfr/asinh.c
index ac6de2595..38ef2915d 100644
--- a/mpfr/asinh.c
+++ b/mpfr/asinh.c
@@ -1,6 +1,6 @@
/* mpfr_asinh -- Inverse Hyperbolic Sinus of Unsigned Integer Number
-Copyright (C) 2001-2002 Free Software Foundation.
+Copyright 2001, 2002 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/atan.c b/mpfr/atan.c
index 94f410f2b..295fb80da 100644
--- a/mpfr/atan.c
+++ b/mpfr/atan.c
@@ -1,6 +1,6 @@
/* mpfr_atan -- arc-tangent of a floating-point number
-Copyright (C) 2001 Free Software Foundation.
+Copyright 2001 Free Software Foundation.
This file is part of the MPFR Library, and was contributed by Mathieu Dutour.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/atanh.c b/mpfr/atanh.c
index 5726a52af..0d1484953 100644
--- a/mpfr/atanh.c
+++ b/mpfr/atanh.c
@@ -1,6 +1,6 @@
/* mpfr_atanh -- Inverse Hyperbolic Tangente of Unsigned Integer Number
-Copyright (C) 2001-2002 Free Software Foundation.
+Copyright 2001, 2002 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/clear.c b/mpfr/clear.c
index 635a02068..508fd3b07 100644
--- a/mpfr/clear.c
+++ b/mpfr/clear.c
@@ -1,6 +1,6 @@
/* mpfr_clear -- free the memory space allocated for a floating-point number
-Copyright (C) 1999-2001 Free Software Foundation.
+Copyright 1999, 2000, 2001 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/cmp.c b/mpfr/cmp.c
index ec6fdd166..327474caf 100644
--- a/mpfr/cmp.c
+++ b/mpfr/cmp.c
@@ -1,6 +1,6 @@
/* mpfr_cmp -- compare two floating-point numbers
-Copyright (C) 1999, 2001 Free Software Foundation.
+Copyright 1999, 2001 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/cmp2.c b/mpfr/cmp2.c
index 46df8c60c..519edb80f 100644
--- a/mpfr/cmp2.c
+++ b/mpfr/cmp2.c
@@ -1,6 +1,6 @@
/* mpfr_cmp2 -- exponent shift when subtracting two numbers.
-Copyright (C) 1999-2001 Free Software Foundation.
+Copyright 1999, 2000, 2001 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/cmp_abs.c b/mpfr/cmp_abs.c
index cae56154e..109ceece4 100644
--- a/mpfr/cmp_abs.c
+++ b/mpfr/cmp_abs.c
@@ -1,6 +1,6 @@
/* mpfr_cmp_abs -- compare the absolute values of two nonzero FP numbers
-Copyright (C) 1999, 2001 Free Software Foundation, Inc.
+Copyright 1999, 2001 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/cmp_ui.c b/mpfr/cmp_ui.c
index 421d2b43a..af115622b 100644
--- a/mpfr/cmp_ui.c
+++ b/mpfr/cmp_ui.c
@@ -1,6 +1,6 @@
/* mpfr_cmp_ui -- compare a floating-point number with a machine integer
-Copyright (C) 1999, 2001 Free Software Foundation, Inc.
+Copyright 1999, 2001 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -78,10 +78,13 @@ mpfr_cmp_si_2exp (mpfr_srcptr b, long int i, int f )
{
int e, k, bn, si; mp_limb_t c, *bp;
- if (MPFR_IS_NAN(b)) return 1;
+ if (MPFR_IS_NAN(b))
+ return 1;
si = (i<0) ? -1 : 1; /* sign of i */
- if (MPFR_SIGN(b) * i < 0 || MPFR_IS_INF(b)) return MPFR_SIGN(b);
+ if ((MPFR_SIGN(b) * si < 0) || MPFR_IS_INF(b))
+ return MPFR_SIGN(b);
+
/* both signs differ */
else if (!MPFR_NOTZERO(b) || (i==0)) { /* one is zero */
if (i==0) return ((MPFR_NOTZERO(b)) ? MPFR_SIGN(b) : 0);
diff --git a/mpfr/const_euler.c b/mpfr/const_euler.c
index 1ae448b81..39711ed0f 100644
--- a/mpfr/const_euler.c
+++ b/mpfr/const_euler.c
@@ -1,6 +1,6 @@
/* mpfr_const_euler -- Euler's constant
-Copyright (C) 2001 Free Software Foundation.
+Copyright 2001 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/const_log2.c b/mpfr/const_log2.c
index e5d368684..e67520ce7 100644
--- a/mpfr/const_log2.c
+++ b/mpfr/const_log2.c
@@ -1,6 +1,6 @@
/* mpfr_const_log2 -- compute natural logarithm of 2
-Copyright (C) 1999, 2001 Free Software Foundation, Inc.
+Copyright 1999, 2001 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/const_pi.c b/mpfr/const_pi.c
index edca47860..3909922de 100644
--- a/mpfr/const_pi.c
+++ b/mpfr/const_pi.c
@@ -1,6 +1,6 @@
/* mpfr_const_pi -- compute Pi
-Copyright (C) 1999-2001 Free Software Foundation.
+Copyright 1999, 2000, 2001 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/copysign.c b/mpfr/copysign.c
index 6a15ec0ce..0b5070df2 100644
--- a/mpfr/copysign.c
+++ b/mpfr/copysign.c
@@ -1,6 +1,6 @@
/* mpfr_copysign -- Produce a value with the magnitude of x and sign of y
-Copyright (C) 2001-2002 Free Software Foundation.
+Copyright 2001, 2002 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/cos.c b/mpfr/cos.c
index dce32c0a0..6c2d122d0 100644
--- a/mpfr/cos.c
+++ b/mpfr/cos.c
@@ -1,6 +1,6 @@
/* mpfr_cos -- cosine of a floating-point number
-Copyright (C) 2001-2002 Free Software Foundation.
+Copyright 2001, 2002 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/cosh.c b/mpfr/cosh.c
index a124585af..b7d8235a0 100644
--- a/mpfr/cosh.c
+++ b/mpfr/cosh.c
@@ -1,6 +1,6 @@
/* mpfr_cosh -- hyperbolic cosine
-Copyright (C) 2001-2002 Free Software Foundation.
+Copyright 2001, 2002 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/dim.c b/mpfr/dim.c
index 39e981c8d..51a35a714 100644
--- a/mpfr/dim.c
+++ b/mpfr/dim.c
@@ -1,6 +1,6 @@
/* mpfr_dim -- dim of x, y
-Copyright (C) 2001-2002 Free Software Foundation.
+Copyright 2001, 2002 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/div.c b/mpfr/div.c
index 865cfdf23..f9690af00 100644
--- a/mpfr/div.c
+++ b/mpfr/div.c
@@ -1,6 +1,6 @@
/* mpfr_div -- divide two floating-point numbers
-Copyright (C) 1999, 2001 Free Software Foundation.
+Copyright 1999, 2001 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/div_2exp.c b/mpfr/div_2exp.c
index 3a9f67e21..dadf3ad24 100644
--- a/mpfr/div_2exp.c
+++ b/mpfr/div_2exp.c
@@ -1,6 +1,6 @@
/* mpfr_div_2exp -- divide a floating-point number by a power of two
-Copyright (C) 1999, 2001 Free Software Foundation, Inc.
+Copyright 1999, 2001 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/div_2si.c b/mpfr/div_2si.c
index d03a06b20..cf553affa 100644
--- a/mpfr/div_2si.c
+++ b/mpfr/div_2si.c
@@ -1,6 +1,6 @@
/* mpfr_div_2si -- divide a floating-point number by a power of two
-Copyright (C) 1999, 2001 Free Software Foundation, Inc.
+Copyright 1999, 2001 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/div_2ui.c b/mpfr/div_2ui.c
index b69a9b874..a2608d805 100644
--- a/mpfr/div_2ui.c
+++ b/mpfr/div_2ui.c
@@ -1,6 +1,6 @@
/* mpfr_div_2ui -- divide a floating-point number by a power of two
-Copyright (C) 1999, 2001 Free Software Foundation, Inc.
+Copyright 1999, 2001 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/div_ui.c b/mpfr/div_ui.c
index 69a44007f..c433cdee9 100644
--- a/mpfr/div_ui.c
+++ b/mpfr/div_ui.c
@@ -1,6 +1,6 @@
/* mpfr_div_ui -- divide a floating-point number by a machine integer
-Copyright (C) 1999-2002 Free Software Foundation, Inc.
+Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/dump.c b/mpfr/dump.c
index 74a7c90ca..d4e0fd30a 100644
--- a/mpfr/dump.c
+++ b/mpfr/dump.c
@@ -1,6 +1,6 @@
/* mpfr_dump -- Dump a float to stdout.
-Copyright (C) 1999, 2001 Free Software Foundation, Inc.
+Copyright 1999, 2001 Free Software Foundation, Inc.
(Copied from the GNU MP Library.)
This file is part of the MPFR Library.
@@ -16,7 +16,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/eq.c b/mpfr/eq.c
index 792728ad0..df8624bcc 100644
--- a/mpfr/eq.c
+++ b/mpfr/eq.c
@@ -1,6 +1,6 @@
/* mpfr_eq -- Compare two floats up to a specified bit #.
-Copyright (C) 1999, 2001 Free Software Foundation, Inc.
+Copyright 1999, 2001 Free Software Foundation, Inc.
(Copied from GNU MP, file mpf_eq.)
This file is part of the MPFR Library.
@@ -16,7 +16,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/exceptions.c b/mpfr/exceptions.c
index de171cba5..8258758d2 100644
--- a/mpfr/exceptions.c
+++ b/mpfr/exceptions.c
@@ -1,6 +1,6 @@
/* Exception flags and utilities.
-Copyright (C) 2001 Free Software Foundation.
+Copyright 2001 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/exp.c b/mpfr/exp.c
index 12be08919..febe28062 100644
--- a/mpfr/exp.c
+++ b/mpfr/exp.c
@@ -1,6 +1,6 @@
/* mpfr_exp -- exponential of a floating-point number
-Copyright (C) 1999-2002 Free Software Foundation.
+Copyright 1999, 2000, 2001, 2002 Free Software Foundation.
Contributed by the Spaces project.
This file is part of the MPFR Library.
@@ -16,7 +16,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -74,7 +74,7 @@ mpfr_exp (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode)
/* result is +Inf when exp(x) >= 2^(__mpfr_emax), i.e.
x >= __mpfr_emax * log(2) */
- d = mpfr_get_d (x);
+ d = mpfr_get_d1 (x);
if (d >= (double) __mpfr_emax * LOG2)
return mpfr_set_overflow(y, rnd_mode, 1);
diff --git a/mpfr/exp2.c b/mpfr/exp2.c
index 8370510a1..bb733b99d 100644
--- a/mpfr/exp2.c
+++ b/mpfr/exp2.c
@@ -1,6 +1,6 @@
/* mpfr_exp2 -- power of 2 function 2^y
-Copyright (C) 2001-2002 Free Software Foundation.
+Copyright 2001, 2002 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -62,6 +62,11 @@ mpfr_exp2 (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode)
if (MPFR_IS_ZERO(x))
return mpfr_set_ui (y, 1, rnd_mode);
+ /* since the smallest representable non-zero float is 1/2*2^__mpfr_emin,
+ if x < __mpfr_emin - 1, the result is either 1/2*2^__mpfr_emin or 0 */
+ if (mpfr_cmp_si_2exp (x, __mpfr_emin - 1, 0) < 0)
+ return mpfr_set_underflow (y, rnd_mode, 1);
+
/* General case */
{
/* Declaration of the intermediary variable */
@@ -75,38 +80,39 @@ mpfr_exp2 (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode)
long int err; /* Precision of error */
/* compute the precision of intermediary variable */
- Nt=MAX(Nx,Ny);
+ Nt = MAX(Nx, Ny);
/* the optimal number of bits : see algorithms.ps */
- Nt=Nt+5+_mpfr_ceil_log2(Nt);
+ Nt = Nt + 5 + _mpfr_ceil_log2 (Nt);
/* initialise of intermediary variable */
- mpfr_init(t);
- mpfr_init(te);
+ mpfr_init (t);
+ mpfr_init (te);
- /* First computation of cosh */
+ /* First computation */
do {
/* reactualisation of the precision */
- mpfr_set_prec(t,Nt);
- mpfr_set_prec(te,Nt);
+ mpfr_set_prec (t, Nt);
+ mpfr_set_prec (te, Nt);
/* compute exp(x*ln(2))*/
- mpfr_const_log2(t,GMP_RNDU); /* ln(2) */
- mpfr_mul(te,x,t,GMP_RNDU); /* x*ln(2) */
- mpfr_exp(t,te,GMP_RNDN); /* exp(x*ln(2))*/
+ mpfr_const_log2 (t, GMP_RNDU); /* ln(2) */
+ mpfr_mul (te, x, t, GMP_RNDU); /* x*ln(2) */
+ mpfr_exp (t, te, GMP_RNDN); /* exp(x*ln(2))*/
/* estimate of the error -- see pow function in algorithms.ps*/
- err=Nt-(MPFR_EXP(te)+2);
+ err = Nt - (MPFR_EXP(te) + 2);
/* actualisation of the precision */
- Nt += 10;
+ Nt += _mpfr_isqrt (Nt) + 10;
- } while ((err<0) || !mpfr_can_round(t,err,GMP_RNDN,rnd_mode,Ny));
+ } while ((err < 0) || !mpfr_can_round (t, err, GMP_RNDN, rnd_mode, Ny));
- inexact = mpfr_set(y,t,rnd_mode);
- mpfr_clear(t);
- mpfr_clear(te);
+ inexact = mpfr_set (y, t, rnd_mode);
+
+ mpfr_clear (t);
+ mpfr_clear (te);
}
return inexact;
diff --git a/mpfr/exp3.c b/mpfr/exp3.c
index c56745eb0..7a944b50d 100644
--- a/mpfr/exp3.c
+++ b/mpfr/exp3.c
@@ -1,6 +1,6 @@
/* mpfr_exp -- exponential of a floating-point number
-Copyright (C) 1999, 2001 Free Software Foundation, Inc.
+Copyright 1999, 2001 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/exp_2.c b/mpfr/exp_2.c
index a8da4f4f9..1e66642e9 100644
--- a/mpfr/exp_2.c
+++ b/mpfr/exp_2.c
@@ -1,7 +1,7 @@
/* mpfr_exp_2 -- exponential of a floating-point number
using Brent's algorithms in O(n^(1/2)*M(n)) and O(n^(1/3)*M(n))
-Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
+Copyright 1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -16,7 +16,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -108,17 +108,13 @@ mpz_normalize2 (mpz_t rop, mpz_t z, int expz, int target)
int
mpfr_exp_2 (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode)
{
- int n, expx, K, precy, q, k, l, err, exps, inexact;
+ int n, K, precy, q, k, l, err, exps, inexact;
mpfr_t r, s, t; mpz_t ss;
TMP_DECL(marker);
- expx = MPFR_EXP(x);
precy = MPFR_PREC(y);
-#ifdef DEBUG
- printf("MPFR_EXP(x)=%d\n",expx);
-#endif
- n = (int) (mpfr_get_d(x) / LOG2);
+ n = (int) (mpfr_get_d1 (x) / LOG2);
/* for the O(n^(1/2)*M(n)) method, the Taylor series computation of
n/K terms costs about n/(2K) multiplications when computed in fixed
@@ -150,9 +146,9 @@ mpfr_exp_2 (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode)
/* r = floor(n*log(2)) */
#ifdef DEBUG
- printf("x=%1.20e\n",mpfr_get_d(x));
+ printf("x=%1.20e\n", mpfr_get_d1 (x));
printf(" ="); mpfr_print_binary(x); putchar('\n');
- printf("r=%1.20e\n",mpfr_get_d(r));
+ printf("r=%1.20e\n", mpfr_get_d1 (r));
printf(" ="); mpfr_print_binary(r); putchar('\n');
#endif
mpfr_sub(r, x, r, GMP_RNDU);
@@ -163,7 +159,7 @@ mpfr_exp_2 (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode)
mpfr_sub(r, x, r, GMP_RNDU);
}
#ifdef DEBUG
- printf("x-r=%1.20e\n",mpfr_get_d(r));
+ printf("x-r=%1.20e\n", mpfr_get_d1 (r));
printf(" ="); mpfr_print_binary(r); putchar('\n');
if (MPFR_SIGN(r)<0) { fprintf(stderr,"Error in mpfr_exp: r<0\n"); exit(1); }
#endif
@@ -198,7 +194,8 @@ mpfr_exp_2 (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode)
K += k;
#ifdef DEBUG
printf("after mult. by 2^n:\n");
- if (MPFR_EXP(s)>-1024) printf("s=%1.20e\n",mpfr_get_d(s));
+ if (MPFR_EXP(s) > -1024)
+ printf("s=%1.20e\n", mpfr_get_d1 (s));
printf(" ="); mpfr_print_binary(s); putchar('\n');
printf("err=%d bits\n", K);
#endif
diff --git a/mpfr/expm1.c b/mpfr/expm1.c
index c3cca2b54..95693da80 100644
--- a/mpfr/expm1.c
+++ b/mpfr/expm1.c
@@ -1,6 +1,6 @@
/* mpfr_expm1 -- Compute exp(x)-1
-Copyright (C) 2001-2002 Free Software Foundation.
+Copyright 2001, 2002 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/extract.c b/mpfr/extract.c
index b4ecda585..b536ebbc6 100644
--- a/mpfr/extract.c
+++ b/mpfr/extract.c
@@ -1,6 +1,6 @@
/* mpfr_extract -- bit-extraction function for the binary splitting algorithm
-Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -24,7 +24,6 @@ MA 02111-1307, USA. */
#include "mpfr.h"
#include "mpfr-impl.h"
-
/* given 0 <= |p| < 1, this function extracts limbs of p and puts them in y.
It is mainly designed for the "binary splitting" algorithm together with
generic.c.
@@ -33,6 +32,7 @@ MA 02111-1307, USA. */
- for i=0, y = floor(p * B)
- for i>0, y = (p * B^(2^i)) mod B^(2^(i-1))
*/
+
void
mpfr_extract (mpz_ptr y, mpfr_srcptr p, unsigned int i)
{
@@ -43,17 +43,15 @@ mpfr_extract (mpz_ptr y, mpfr_srcptr p, unsigned int i)
/* as 0 <= |p| < 1, we don't have to care with infinities, NaN, ... */
_mpz_realloc (y, two_i_2);
- if (size_p < two_i) {
- MPN_ZERO (PTR(y), two_i_2);
- if (size_p >= two_i_2)
- MPN_COPY (PTR(y) + two_i - size_p, MPFR_MANT(p), size_p - two_i_2);
- }
+ if (size_p < two_i)
+ {
+ MPN_ZERO (PTR(y), two_i_2);
+ if (size_p >= two_i_2)
+ MPN_COPY (PTR(y) + two_i - size_p, MPFR_MANT(p), size_p - two_i_2);
+ }
else
MPN_COPY (PTR(y), MPFR_MANT(p) + size_p - two_i, two_i_2);
MPN_NORMALIZE (PTR(y), two_i_2);
SIZ(y) = (MPFR_ISNEG(p)) ? -two_i_2 : two_i_2;
}
-
-
-
diff --git a/mpfr/factorial.c b/mpfr/factorial.c
index eddabea2d..f5fe52802 100644
--- a/mpfr/factorial.c
+++ b/mpfr/factorial.c
@@ -1,6 +1,6 @@
/* mpfr_fac_ui -- factorial of a non-negative integer
-Copyright (C) 2001 Free Software Foundation, Inc.
+Copyright 2001 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/fma.c b/mpfr/fma.c
index 8abebc743..4ded04629 100644
--- a/mpfr/fma.c
+++ b/mpfr/fma.c
@@ -1,6 +1,6 @@
/* mpfr_fma -- Floating multiply-add
-Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+Copyright 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -18,7 +18,7 @@ License for more details.
You should have received a copy of the GNU Lesser
General Public License along with the MPFR Library; see
-the file COPYING.LIB. If not, write to the Free Software
+the file COPYING. If not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -36,9 +36,8 @@ int
mpfr_fma (mpfr_ptr s, mpfr_srcptr x, mpfr_srcptr y, mpfr_srcptr z,
mp_rnd_t rnd_mode)
{
- int inexact = 0;
- /* Flag calcul exacte */
- int not_exact = 0;
+ int inexact;
+ mpfr_t u;
/* particular cases */
if (MPFR_IS_NAN(x) || MPFR_IS_NAN(y) || MPFR_IS_NAN(z))
@@ -111,95 +110,12 @@ mpfr_fma (mpfr_ptr s, mpfr_srcptr x, mpfr_srcptr y, mpfr_srcptr z,
if (MPFR_IS_ZERO(z))
return mpfr_mul (s, x, y, rnd_mode);
-
- /* General case */
- /* Detail of the compute */
-
- /* u <- x*y */
- /* t <- z+u */
- {
- /* Declaration of the intermediary variable */
- mpfr_t t, u;
- int d;
- int accu = 0;
-
- /* Declaration of the size variable */
- mp_prec_t Nx = MPFR_PREC(x); /* Precision of input variable */
- mp_prec_t Ny = MPFR_PREC(y); /* Precision of input variable */
- mp_prec_t Nz = MPFR_PREC(z); /* Precision of input variable */
- mp_prec_t Ns = MPFR_PREC(s); /* Precision of output variable */
- mp_prec_t Nt; /* Precision of the intermediary variable */
- long int err; /* Precision of error */
- unsigned int first_pass = 0; /* temporary precision */
-
- /* compute the precision of intermediary variable */
- Nt = MAX(MAX(Nx,Ny),Nz);
-
- /* the optimal number of bits is MPFR_EXP(u)-MPFR_EXP(v)+1 */
- /* but u and v are not yet compute, also we take in account */
- /* just one bit */
- Nt += 1 + _mpfr_ceil_log2(Nt) + 20;
- /* initialise the intermediary variables */
- mpfr_init(u);
- mpfr_init(t);
-
- /* First computation of fma */
- do
- {
- if (accu++ > 2)
- {
- mpfr_clear(t);
- mpfr_clear(u);
-
- /* General case */
- /* Detail of the compute */
- /* u <- x*y exact */
- /* s <- z+u */
-
- /* if we take prec(u) >= prec(x) + prec(y), the product
- u <- x*y is always exact */
- mpfr_init2 (u, MPFR_PREC(x) + MPFR_PREC(y));
- mpfr_mul (u, x, y, GMP_RNDN); /* always exact */
- inexact = mpfr_add (s, z, u, rnd_mode);
- mpfr_clear(u);
- return inexact;
- }
-
- /* reactualisation of the precision */
- mpfr_set_prec(u, Nt);
- mpfr_set_prec(t, Nt);
-
- /* computations */
- not_exact = mpfr_mul (u, x, y, GMP_RNDN);
-
- not_exact |= mpfr_add (t, z, u, GMP_RNDN);
-
- /* Nt = Nt + (d+1) + _mpfr_ceil_log2(Nt); */
- d = MPFR_EXP(u) - MPFR_EXP(t);
-
- /* estimate of the error */
- err = Nt - (d+1);
-
- /* actualisation of the precision */
- Nt += (1-first_pass) * d + first_pass * 10;
- if (Nt < 0)
- Nt = 0;
-
- first_pass = 1;
- }
- while (not_exact &&
- ((err < 0) || !mpfr_can_round (t, err, GMP_RNDN, rnd_mode, Ns)));
-
- inexact = mpfr_set (s, t, rnd_mode);
- mpfr_clear(t);
- mpfr_clear(u);
- }
-
- if (not_exact == 0 && inexact == 0)
- return 0;
-
- if (not_exact != 0 && inexact == 0)
- return 1;
+ /* if we take prec(u) >= prec(x) + prec(y), the product
+ u <- x*y is always exact */
+ mpfr_init2 (u, MPFR_PREC(x) + MPFR_PREC(y));
+ mpfr_mul (u, x, y, GMP_RNDN); /* always exact */
+ inexact = mpfr_add (s, z, u, rnd_mode);
+ mpfr_clear(u);
return inexact;
}
diff --git a/mpfr/generic.c b/mpfr/generic.c
index d1b459513..f578f1349 100644
--- a/mpfr/generic.c
+++ b/mpfr/generic.c
@@ -1,6 +1,6 @@
/* generic file for evaluation of hypergeometric series using binary splitting
-Copyright (C) 1999-2001 Free Software Foundation.
+Copyright 1999, 2000, 2001 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/get_str.c b/mpfr/get_str.c
index 1117a6946..5320d6f18 100644
--- a/mpfr/get_str.c
+++ b/mpfr/get_str.c
@@ -1,6 +1,6 @@
/* mpfr_get_str -- output a floating-point number to a string
-Copyright (C) 1999-2002 Free Software Foundation, Inc.
+Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -138,7 +138,7 @@ mpfr_get_str (char *str, mp_exp_t *expptr, int base, size_t n,
{
double d;
- d = mpfr_get_d2(op, 0);
+ d = mpfr_get_d3(op, 0, GMP_RNDN);
d = ((double) e + (double) _mpfr_floor_log2 (ABS(d)))
* __mp_bases[base].chars_per_bit_exactly;
MPFR_ASSERTN(d >= MP_EXP_T_MIN);
diff --git a/mpfr/gmp_op.c b/mpfr/gmp_op.c
index 15925c941..d4b854319 100644
--- a/mpfr/gmp_op.c
+++ b/mpfr/gmp_op.c
@@ -1,6 +1,6 @@
/* mpfr_cos -- cosine of a floating-point number
-Copyright (C) 2001 Free Software Foundation, Inc.
+Copyright 2001 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/hypot.c b/mpfr/hypot.c
index 6ee55942e..376453492 100644
--- a/mpfr/hypot.c
+++ b/mpfr/hypot.c
@@ -1,6 +1,6 @@
/* mpfr_hypot -- Euclidean distance
-Copyright (C) 2001-2002 Free Software Foundation, Inc.
+Copyright 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/i_ceil_exp2.c b/mpfr/i_ceil_exp2.c
deleted file mode 100644
index 94f7e85e0..000000000
--- a/mpfr/i_ceil_exp2.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/* _mpfr_ceil_exp2 - returns y >= 2^d
-
-Copyright (C) 1999-2002 Free Software Foundation.
-
-This file is part of the MPFR Library.
-
-The MPFR Library is free software; you can redistribute it and/or modify
-it under the terms of the GNU Lesser General Public License as published by
-the Free Software Foundation; either version 2.1 of the License, or (at your
-option) any later version.
-
-The MPFR Library is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
-License for more details.
-
-You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
-the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-MA 02111-1307, USA. */
-
-#include "gmp.h"
-#include "gmp-impl.h"
-#include "mpfr.h"
-#include "mpfr-impl.h"
-
-/* returns y >= 2^d, assuming that d <= 1024 */
-double
-_mpfr_ceil_exp2 (double d)
-{
- long exp;
- union ieee_double_extract x;
-
- MPFR_ASSERTN(d <= 1024.0);
- exp = (long) d;
- if (d != (double) exp)
- exp++;
- /* now exp = ceil(d) */
- x.d = 1.0;
- x.s.exp = exp <= -1022 ? 1 : 1023 + exp;
- return x.d;
-}
diff --git a/mpfr/i_ceil_log2.c b/mpfr/i_ceil_log2.c
deleted file mode 100644
index e70dd261d..000000000
--- a/mpfr/i_ceil_log2.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/* _mpfr_ceil_log2 - returns ceil(log(d)/log(2))
-
-Copyright (C) 1999-2002 Free Software Foundation.
-
-This file is part of the MPFR Library.
-
-The MPFR Library is free software; you can redistribute it and/or modify
-it under the terms of the GNU Lesser General Public License as published by
-the Free Software Foundation; either version 2.1 of the License, or (at your
-option) any later version.
-
-The MPFR Library is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
-License for more details.
-
-You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
-the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-MA 02111-1307, USA. */
-
-#include "gmp.h"
-#include "gmp-impl.h"
-#include "mpfr.h"
-#include "mpfr-impl.h"
-
-/* returns ceil(log(d)/log(2)) */
-long
-_mpfr_ceil_log2 (double d)
-{
- long exp;
- union ieee_double_extract x;
-
- x.d = d;
- exp = x.s.exp - 1023;
- x.s.exp = 1023; /* value for 1 <= d < 2 */
- if (x.d != 1.0) /* d: not a power of two? */
- exp++;
- return exp;
-}
diff --git a/mpfr/i_floor_log2.c b/mpfr/i_floor_log2.c
deleted file mode 100644
index a4879610e..000000000
--- a/mpfr/i_floor_log2.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/* _mpfr_floor_log2 - returns floor(log(d)/log(2))
-
-Copyright (C) 1999-2002 Free Software Foundation.
-
-This file is part of the MPFR Library.
-
-The MPFR Library is free software; you can redistribute it and/or modify
-it under the terms of the GNU Lesser General Public License as published by
-the Free Software Foundation; either version 2.1 of the License, or (at your
-option) any later version.
-
-The MPFR Library is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
-License for more details.
-
-You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
-the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-MA 02111-1307, USA. */
-
-#include "gmp.h"
-#include "gmp-impl.h"
-#include "mpfr.h"
-#include "mpfr-impl.h"
-
-/* returns floor(log(d)/log(2)) */
-long
-_mpfr_floor_log2 (double d)
-{
- union ieee_double_extract x;
-
- x.d = d;
- return (long) x.s.exp - 1023;
-}
diff --git a/mpfr/init.c b/mpfr/init.c
index 44f6eeae4..36fdbd4fd 100644
--- a/mpfr/init.c
+++ b/mpfr/init.c
@@ -1,6 +1,6 @@
/* mpfr_init -- initialize a floating-point number
-Copyright (C) 1999, 2001 Free Software Foundation, Inc.
+Copyright 1999, 2001 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/init2.c b/mpfr/init2.c
index 2b516df1b..576e59fc6 100644
--- a/mpfr/init2.c
+++ b/mpfr/init2.c
@@ -1,6 +1,6 @@
/* mpfr_init2 -- initialize a floating-point number with given precision
-Copyright (C) 2001 Free Software Foundation, Inc.
+Copyright 2001 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/inp_str.c b/mpfr/inp_str.c
index a218f8c3c..10d55f782 100644
--- a/mpfr/inp_str.c
+++ b/mpfr/inp_str.c
@@ -1,7 +1,7 @@
/* mpf_inp_str(dest_float, stream, base) -- Input a number in base
BASE from stdio stream STREAM and store the result in DEST_FLOAT.
-Copyright (C) 1999, 2001 Free Software Foundation, Inc.
+Copyright 1999, 2001 Free Software Foundation, Inc.
(Copied from GMP, file mpf/inp_str.c)
This file is part of the MPFR Library.
@@ -17,7 +17,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/isinf.c b/mpfr/isinf.c
index 04d86edfc..e0a638b21 100644
--- a/mpfr/isinf.c
+++ b/mpfr/isinf.c
@@ -1,6 +1,6 @@
/* mpfr_inf_p -- check for infinities
-Copyright (C) 2000-2001 Free Software Foundation.
+Copyright 2000, 2001 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/isinteger.c b/mpfr/isinteger.c
index 84e990d0c..9ec2181f8 100644
--- a/mpfr/isinteger.c
+++ b/mpfr/isinteger.c
@@ -1,6 +1,6 @@
/* mpfr_isinteger -- test if a mpfr variable is integer
-Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+Copyright 2001 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/isnan.c b/mpfr/isnan.c
index acd3d3dd7..c75f76ae8 100644
--- a/mpfr/isnan.c
+++ b/mpfr/isnan.c
@@ -1,6 +1,6 @@
/* mpfr_nan_p -- check for NaN
-Copyright (C) 2000-2001 Free Software Foundation.
+Copyright 2000, 2001 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/isnum.c b/mpfr/isnum.c
index cedfab3ac..d9b33201e 100644
--- a/mpfr/isnum.c
+++ b/mpfr/isnum.c
@@ -1,6 +1,6 @@
/* mpfr_number_p -- check for ordinary numbers
-Copyright (C) 2000-2001 Free Software Foundation.
+Copyright 2000, 2001 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/log.c b/mpfr/log.c
index 97b1607af..3bea8a3f1 100644
--- a/mpfr/log.c
+++ b/mpfr/log.c
@@ -1,6 +1,6 @@
/* mpfr_log -- natural logarithm of a floating-point number
-Copyright (C) 1999-2002 Free Software Foundation.
+Copyright 1999, 2000, 2001, 2002 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -82,8 +82,8 @@ mpfr_log (mpfr_ptr r, mpfr_srcptr a, mp_rnd_t rnd_mode)
if (MPFR_IS_ZERO(a))
{
MPFR_SET_INF(r);
- MPFR_SET_POS(r);
- MPFR_RET(0); /* log(0) is an exact infinity */
+ MPFR_SET_NEG(r);
+ MPFR_RET(0); /* log(0) is an exact -infinity */
}
/* If a is negative, the result is NaN */
@@ -103,7 +103,7 @@ mpfr_log (mpfr_ptr r, mpfr_srcptr a, mp_rnd_t rnd_mode)
q=MPFR_PREC(r);
- ref=mpfr_get_d(a)-1.0;
+ ref = mpfr_get_d1 (a) - 1.0;
if (ref<0)
ref=-ref;
diff --git a/mpfr/log10.c b/mpfr/log10.c
index a182d0c84..8eae79890 100644
--- a/mpfr/log10.c
+++ b/mpfr/log10.c
@@ -1,6 +1,6 @@
/* mpfr_log10 -- logarithm in base 10.
-Copyright (C) 2001-2002 Free Software Foundation, Inc.
+Copyright 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -66,8 +66,8 @@ mpfr_log10 (mpfr_ptr r, mpfr_srcptr a, mp_rnd_t rnd_mode)
if (MPFR_IS_ZERO(a))
{
MPFR_SET_INF(r);
- MPFR_SET_POS(r);
- MPFR_RET(0); /* log10(0) is an exact +infinity */
+ MPFR_SET_NEG(r);
+ MPFR_RET(0); /* log10(0) is an exact -infinity */
}
/* If a is negative, the result is NaN */
@@ -128,7 +128,7 @@ mpfr_log10 (mpfr_ptr r, mpfr_srcptr a, mp_rnd_t rnd_mode)
/* log10(10^n) is exact */
if ((MPFR_SIGN(t) > 0) && mpfr_isinteger(t))
- if (mpfr_ui_pow_ui (tt, 10, (unsigned long int) mpfr_get_d (t) + 0.5,
+ if (mpfr_ui_pow_ui (tt, 10, (unsigned long int) mpfr_get_d1 (t) + 0.5,
GMP_RNDN) == 0)
if (mpfr_cmp (a, tt) == 0)
ok = 1;
diff --git a/mpfr/log1p.c b/mpfr/log1p.c
index ae3e410a5..fa7576367 100644
--- a/mpfr/log1p.c
+++ b/mpfr/log1p.c
@@ -1,6 +1,6 @@
/* mpfr_log1p -- Compute log(1+x)
-Copyright (C) 2001-2002 Free Software Foundation, Inc.
+Copyright 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/log2.c b/mpfr/log2.c
index 80db9911e..0c6e1ef9e 100644
--- a/mpfr/log2.c
+++ b/mpfr/log2.c
@@ -1,6 +1,6 @@
/* mpfr_log2 -- log base 2
-Copyright (C) 2001-2002 Free Software Foundation, Inc.
+Copyright 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -66,8 +66,8 @@ mpfr_log2 (mpfr_ptr r, mpfr_srcptr a, mp_rnd_t rnd_mode)
if (MPFR_IS_ZERO(a))
{
MPFR_SET_INF(r);
- MPFR_SET_POS(r);
- MPFR_RET(0); /* log(0) is an exact infinity */
+ MPFR_SET_NEG(r);
+ MPFR_RET(0); /* log2(0) is an exact -infinity */
}
/* If a is negative, the result is NaN */
diff --git a/mpfr/minmax.c b/mpfr/minmax.c
index bc57da7e4..e76f9cb7d 100644
--- a/mpfr/minmax.c
+++ b/mpfr/minmax.c
@@ -1,6 +1,6 @@
/* mpfr_min -- min and max of x, y
-Copyright (C) 2001 Free Software Foundation, Inc.
+Copyright 2001 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/mpf2mpfr.h b/mpfr/mpf2mpfr.h
index cdb374916..e4470a789 100644
--- a/mpfr/mpf2mpfr.h
+++ b/mpfr/mpf2mpfr.h
@@ -1,6 +1,6 @@
/* mpf2mpfr.h -- Compatibility include file with mpf.
-Copyright (C) 1999-2002 Free Software Foundation, Inc.
+Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -38,7 +38,7 @@ MA 02111-1307, USA. */
#undef mpf_floor
#define mpf_floor mpfr_floor
#undef mpf_get_d
-#define mpf_get_d mpfr_get_d
+#define mpf_get_d mpfr_get_d1
#undef mpf_get_prec
#define mpf_get_prec mpfr_get_prec
#undef mpf_init
diff --git a/mpfr/mpfr-impl.h b/mpfr/mpfr-impl.h
index 0eb06aa08..846f62e40 100644
--- a/mpfr/mpfr-impl.h
+++ b/mpfr/mpfr-impl.h
@@ -1,6 +1,6 @@
/* Utilities for MPFR developers, not exported.
-Copyright (C) 1999-2002 Free Software Foundation, Inc.
+Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -81,6 +81,10 @@ typedef union ieee_double_extract Ieee_double_extract;
((((Ieee_double_extract *)&(x))->s.manl != 0) || \
(((Ieee_double_extract *)&(x))->s.manh != 0)))
+#define DBL_POS_INF (1.0/0.0)
+#define DBL_NEG_INF (-1.0/0.0)
+#define DBL_NAN (0.0/0.0)
+
/* bit 31 of _mpfr_size is used for sign,
bit 30 of _mpfr_size is used for Nan flag,
bit 29 of _mpfr_size is used for Inf flag,
@@ -180,8 +184,7 @@ int mpfr_round_raw_generic _PROTO ((mp_limb_t *, mp_limb_t *, mp_prec_t, int,
mp_prec_t, mp_rnd_t, int *, int));
int mpfr_can_round_raw _PROTO ((mp_limb_t *, mp_size_t, int, mp_exp_t,
mp_rnd_t, mp_rnd_t, mp_prec_t));
-double mpfr_get_d2 _PROTO ((mpfr_srcptr, mp_exp_t));
-mp_size_t mpn_sqrtrem_new _PROTO ((mp_limb_t *, mp_limb_t *, mp_limb_t *, mp_size_t));
+double mpfr_get_d3 _PROTO ((mpfr_srcptr, mp_exp_t, mp_rnd_t));
int mpfr_cmp_abs _PROTO ((mpfr_srcptr, mpfr_srcptr));
int mpfr_cmp2 _PROTO ((mpfr_srcptr, mpfr_srcptr, mp_prec_t *));
long _mpfr_ceil_log2 _PROTO ((double));
diff --git a/mpfr/mpfr-test.h b/mpfr/mpfr-test.h
index a436a5fb6..ba119ff2b 100644
--- a/mpfr/mpfr-test.h
+++ b/mpfr/mpfr-test.h
@@ -1,6 +1,6 @@
/* auxiliary functions for MPFR tests.
-Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -24,11 +24,42 @@ MA 02111-1307, USA. */
#include <sys/fpu.h>
#endif
+/* set precision control to double on x86 */
+#if (defined (__i386__) || defined (__i486__))
+#ifdef __CYGWIN32__ /* no fpu_control.h under Cygnus */
+#define _FPU_EXTENDED 0x300
+#define _FPU_DOUBLE 0x200
+#define _FPU_DEFAULT 0x137f
+#define HAVE_SETFPUCW
+#else
+#ifdef HAVE_FPU_CONTROL_H
+#include <fpu_control.h>
+#define HAVE_SETFPUCW
+#endif
+#endif /* ifdef __CYGWIN32__ */
+#ifndef __setfpucw
+#define __setfpucw(cw) __asm__ ("fldcw %0" : : "m" (cw))
+#endif /* ifndef __setfpucw */
+#endif /* __i386__ */
+
+/* generates a random long int, a random double,
+ and corresponding seed initializing */
+#ifdef HAVE_LRAND48
+#define LONG_RAND lrand48
+#define DBL_RAND drand48
+#define SEED_RAND srand48
+#else
+#define LONG_RAND random
+#define DBL_RAND() ((double) random() / (double) RAND_MAX)
+#define SEED_RAND srandom
+#endif
+
#if defined (__hpux)
#define srandom srand48
#define random() (mrand48() & 0x7fffffff)
#endif
+void mpfr_test_init _PROTO ((void));
double drand _PROTO ((void));
int ulp _PROTO ((double, double));
double dbl _PROTO ((double, int));
@@ -48,6 +79,25 @@ double Ulp _PROTO ((double));
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define ABS(x) (((x)>0) ? (x) : -(x))
+/* initialization function for tests using the hardware floats */
+void
+mpfr_test_init ()
+{
+#ifdef __mips
+ /* to get denormalized numbers on IRIX64 */
+ union fpc_csr exp;
+
+ exp.fc_word = get_fpc_csr();
+ exp.fc_struct.flush = 0;
+ set_fpc_csr(exp.fc_word);
+#endif
+
+#ifdef HAVE_SETFPUCW
+ /* sets the precision to double */
+ __setfpucw((_FPU_DEFAULT & (~_FPU_EXTENDED)) | _FPU_DOUBLE);
+#endif
+}
+
/* generate a random double using the whole range of possible values,
including denormalized numbers, NaN, infinities, ... */
double
@@ -57,12 +107,16 @@ drand (void)
i = (int*) &d;
d = 1.0;
- if (i[0]==0) expo=1; /* little endian, exponent in i[1] */
- else expo=0;
- i[0] = lrand48();
- i[1] = lrand48();
- while (i[expo]>=2146435072) i[expo] = lrand48(); /* avoids NaNs */
- if (lrand48()%2 && !isnan(d)) d=-d; /* generates negative numbers */
+ if (i[0] == 0)
+ expo = 1; /* little endian, exponent in i[1] */
+ else
+ expo = 0;
+ i[0] = LONG_RAND();
+ i[1] = LONG_RAND();
+ while (i[expo] >= 2146435072)
+ i[expo] = LONG_RAND(); /* avoids NaNs */
+ if ((LONG_RAND() % 2) && !isnan (d))
+ d = -d; /* generates negative numbers */
return d;
}
diff --git a/mpfr/mpfr.h b/mpfr/mpfr.h
index 91ab8d1e6..1cf965d3f 100644
--- a/mpfr/mpfr.h
+++ b/mpfr/mpfr.h
@@ -1,6 +1,6 @@
/* mpfr.h -- Include file for mpfr.
-Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -143,9 +143,12 @@ int mpfr_can_round _PROTO ((mpfr_ptr, mp_exp_t, mp_rnd_t, mp_rnd_t,
mp_prec_t));
int mpfr_set_d _PROTO ((mpfr_ptr, double, mp_rnd_t));
int mpfr_set_z _PROTO ((mpfr_ptr, mpz_srcptr, mp_rnd_t));
+void mpfr_set_nan _PROTO ((mpfr_ptr));
+void mpfr_set_inf _PROTO ((mpfr_ptr, int));
mp_exp_t mpfr_get_z_exp _PROTO ((mpz_ptr, mpfr_srcptr));
int mpfr_set_q _PROTO ((mpfr_ptr, mpq_srcptr, mp_rnd_t));
-double mpfr_get_d _PROTO ((mpfr_srcptr));
+double mpfr_get_d1 _PROTO ((mpfr_srcptr));
+double mpfr_get_d _PROTO ((mpfr_srcptr, mp_rnd_t));
int mpfr_set_f _PROTO ((mpfr_ptr, mpf_srcptr, mp_rnd_t));
int mpfr_set_si _PROTO ((mpfr_ptr, long, mp_rnd_t));
int mpfr_set_ui _PROTO ((mpfr_ptr, unsigned long, mp_rnd_t));
diff --git a/mpfr/mpfr.texi b/mpfr/mpfr.texi
index 5b2001d16..05f8a8323 100644
--- a/mpfr/mpfr.texi
+++ b/mpfr/mpfr.texi
@@ -563,17 +563,17 @@ The precision @var{prec} can be any integer between @code{MPFR_PREC_MIN} and
@code{MPFR_PREC_MAX}.
@end deftypefun
-@c @deftypefun void mpfr_set_machine_rnd_mode (mp_rnd_t @var{rnd})
-@c Set the machine rounding mode to @var{rnd}.
-@c This function is useful for debugging purpose, but
-@c also as a common interface to all different ways of setting the
-@c rounding mode, which unfortunately differ from one operating system to
-@c another one.
-@c @end deftypefun
+@deftypefun void mpfr_set_machine_rnd_mode (mp_rnd_t @var{rnd})
+Set the machine rounding mode to @var{rnd}.
+This function is provided only when the operating system supports the
+ISOC9X standard interface for setting rounding modes (i.e. through the
+header file <fenv.h>).
+@end deftypefun
@deftypefun {char *} mpfr_print_rnd_mode (mp_rnd_t @var{rnd})
Returns the input string (GMP_RNDD, GMP_RNDU, GMP_RNDN, GMP_RNDZ)
-corresponding to the rounding mode @var{rnd}.
+corresponding to the rounding mode @var{rnd} or a null pointer if
+@var{rnd} is an invalid rounding mode.
@end deftypefun
@node Exceptions, Initializing Floats, Rounding Modes, Floating-point Functions
@@ -701,6 +701,7 @@ a call to @code{mpfr_clear(x)} followed by a call to
case the current allocated space for the mantissa of @var{x} is enough.
The precision @var{prec} can be any integer between @code{MPFR_PREC_MIN} and
@code{MPFR_PREC_MAX}.
+It returns a non-zero value iff the memory allocation failed.
In case you want to keep the previous value stored in @var{x},
use @code{mpfr_round_prec} instead.
@@ -776,6 +777,13 @@ The returned value is zero when @var{x}=@var{y}, positive when @var{x}>@var{y},
and negative when @var{x}<@var{y}.
@end deftypefun
+@deftypefun void mpfr_set_inf (mpfr_t @var{x}, int @var{sign})
+@deftypefunx void mpfr_set_nan (mpfr_t @var{x})
+Set the variable @var{x} to infinity or NaN (Not-a-Number) respectively.
+In @code{mpfr_set_inf}, @var{x} is set to plus infinity iff @var{sign} is
+positive.
+@end deftypefun
+
@deftypefun void mpfr_swap (mpfr_t @var{x}, mpfr_t @var{y})
Swap the values @var{x} and @var{y} efficiently. Warning: the
precisions are exchanged too; in case the precisions are different,
@@ -792,7 +800,7 @@ using a third auxiliary variable.
@deftypefnx Macro int mpfr_init_set_ui (mpfr_t @var{rop}, unsigned long int @var{op}, mp_rnd_t @var{rnd})
@deftypefnx Macro int mpfr_init_set_si (mpfr_t @var{rop}, signed long int @var{op}, mp_rnd_t @var{rnd})
@deftypefnx Macro int mpfr_init_set_d (mpfr_t @var{rop}, double @var{op}, mp_rnd_t @var{rnd})
-@deftypefnx Macro int mpfr_init_set_f (mpfr_t @var{rop}, double @var{op}, mp_rnd_t @var{rnd})
+@deftypefnx Macro int mpfr_init_set_f (mpfr_t @var{rop}, mpf_t @var{op}, mp_rnd_t @var{rnd})
@deftypefnx Macro int mpfr_init_set_z (mpfr_t @var{rop}, mpz_t @var{op}, mp_rnd_t @var{rnd})
@deftypefnx Macro int mpfr_init_set_q (mpfr_t @var{rop}, mpq_t @var{op}, mp_rnd_t @var{rnd})
Initialize @var{rop} and set its value from @var{op}, rounded to direction
@@ -815,8 +823,13 @@ See @code{mpfr_set_str}.
@section Conversion Functions
@cindex Conversion functions
-@deftypefun double mpfr_get_d (mpfr_t @var{op})
-Convert @var{op} to a double, using the current @emph{machine} rounding mode.
+@deftypefun double mpfr_get_d (mpfr_t @var{op}, mp_rnd_t @var{rnd})
+Convert @var{op} to a double, using the rounding mode @var{rnd}.
+@end deftypefun
+
+@deftypefun double mpfr_get_d1 (mpfr_t @var{op})
+Convert @var{op} to a double, using the default MPFR rounding mode
+(see function @code{mpfr_set_default_rounding_mode}).
@end deftypefun
@deftypefun mp_exp_t mpfr_get_z_exp (mpz_t @var{z}, mpfr_t @var{op})
@@ -1132,6 +1145,14 @@ rounded to the direction @var{rnd} with their corresponding precisions.
Return 0 iff both results are exact.
@end deftypefun
+@deftypefun int mpfr_acos (mpfr_t @var{rop}, mpfr_t @var{op}, mp_rnd_t @var{rnd})
+@deftypefunx int mpfr_asin (mpfr_t @var{rop}, mpfr_t @var{op}, mp_rnd_t @var{rnd})
+@deftypefunx int mpfr_atan (mpfr_t @var{rop}, mpfr_t @var{op}, mp_rnd_t @var{rnd})
+Set @var{rop} to the arc-cosine, arc-sine or arc-tangent of @var{op},
+rounded to the direction @var{rnd} with the precision of @var{rop}.
+Return 0 iff the result is exact.
+@end deftypefun
+
@deftypefun int mpfr_cosh (mpfr_t @var{cop}, mpfr_t @var{op}, mp_rnd_t @var{rnd})
@deftypefunx int mpfr_sinh (mpfr_t @var{sop}, mpfr_t @var{op}, mp_rnd_t @var{rnd})
@deftypefunx int mpfr_tanh (mpfr_t @var{top}, mpfr_t @var{op}, mp_rnd_t @var{rnd})
@@ -1188,14 +1209,6 @@ Set @var{rop} to the arithmetic-geometric mean of @var{op1} and @var{op2},
rounded to the direction @var{rnd} with the precision of @var{rop}.
@end deftypefun
-@deftypefun int mpfr_acos (mpfr_t @var{rop}, mpfr_t @var{op}, mp_rnd_t @var{rnd})
-@deftypefunx int mpfr_asin (mpfr_t @var{rop}, mpfr_t @var{op}, mp_rnd_t @var{rnd})
-@deftypefunx int mpfr_atan (mpfr_t @var{rop}, mpfr_t @var{op}, mp_rnd_t @var{rnd})
-Set @var{rop} to the arc-cosine, arc-sine or arc-tangent of @var{op},
-rounded to the direction @var{rnd} with the precision of @var{rop}.
-Return 0 iff the result is exact.
-@end deftypefun
-
@deftypefun void mpfr_const_log2 (mpfr_t @var{rop}, mp_rnd_t @var{rnd})
Set @var{rop} to the logarithm of 2 rounded to the direction @var{rnd}
with the precision of @var{rop}. This function stores the computed
@@ -1315,8 +1328,7 @@ Generate a uniformly distributed random float in the interval 0 <= X < 1.
@end deftypefun
@deftypefun void mpfr_random (mpfr_t @var{rop})
-Put in @var{rop} a random float in the interval [0,1[.
-Random limbs are generated using the @code{random} system function.
+Generate a uniformly distributed random float in the interval 0 <= X < 1.
@end deftypefun
@deftypefun void mpfr_random2 (mpfr_t @var{rop}, mp_size_t @var{max_size}, mp_exp_t @var{max_exp})
@@ -1338,12 +1350,54 @@ Negative random numbers are generated when @var{max_size} is negative.
@c releases.}
@c @end deftypefun
-@section Internal Functions
+@section Internals
-These functions were mainly designed for the implementation of @code{mpfr},
+These types and
+functions were mainly designed for the implementation of @code{mpfr},
but may be useful for users too.
+However no upward compatibility is guaranteed.
You need to include @code{mpfr-impl.h} to use them.
+The @code{mpfr_t} type consists of four fields.
+The @code{_mpfr_prec} field is used to store the precision of
+the variable (in bits); this is not less than 2.
+
+The @code{_mpfr_size} field is used to store the number of
+allocated limbs, with the high bits reserved to store
+the sign (bit 31), the NaN flag (bit 30),
+and the Infinity flag (bit 29);
+thus bits 0 to 28 remain for the number of allocated limbs, with a maximal
+value of 536870911.
+A NaN is indicated by the NaN flag set, and no other fields are
+relevant.
+An Infinity is indicated by the NaN flag clear and the Inf flag set;
+the sign bit of an Infinity indicates the sign, the limb data
+and the exponent are not relevant.
+
+The @code{_mpfr_exp} field stores the exponent.
+An exponent of 0 means a radix point just above the most significant
+limb. Non-zero values are a multiplier @math{2^n} relative to that
+point.
+
+Finally, the @code{_mpfr_d} is a pointer to the limbs, least
+significant limbs stored first.
+The number zero is represented with its most significant limb set to zero,
+i.e. @code{_mpfr_d[n-1]} where
+n=ceil(@code{_mpfr_prec}/@code{BITS_PER_MP_LIMB}).
+The number of limbs in use is controlled by @code{_mpfr_prec}, namely
+ceil(@code{_mpfr_prec}/@code{BITS_PER_MP_LIMB}).
+Zero is represented by the most significant limb being zero, other
+limb data and the exponent are not relevant
+("not relevant" implies that the corresponding objects may contain
+invalid values, thus should not be evaluated even if
+they are not taken into account).
+Non-zero values always have the most significant bit of the most
+significant limb set to 1. When the precision is not a whole number
+of limbs, the excess bits at the low end of the data are zero.
+When the precision has been lowered by @code{mpfr_set_prec}, the space
+allocated at @code{_mpfr_d} remains as given by @code{_mpfr_size}, but
+@code{_mpfr_prec} indicates how much of that space is actually used.
+
@deftypefun int mpfr_add_one_ulp (mpfr_t @var{x}, mp_rnd_t @var{rnd})
Add one unit in last place (ulp) to @var{x} if @var{x} is finite
and positive, subtract one ulp if @var{x} is finite and negative;
diff --git a/mpfr/mpz_set_fr.c b/mpfr/mpz_set_fr.c
deleted file mode 100644
index da30e5479..000000000
--- a/mpfr/mpz_set_fr.c
+++ /dev/null
@@ -1,71 +0,0 @@
-/* mpfr_get_z_exp -- get a multiple-precision integer and an exponent
- from a floating-point number
-
-Copyright (C) 2000-2002 Free Software Foundation, Inc.
-
-This file is part of the MPFR Library.
-
-The MPFR Library is free software; you can redistribute it and/or modify
-it under the terms of the GNU Lesser General Public License as published by
-the Free Software Foundation; either version 2.1 of the License, or (at your
-option) any later version.
-
-The MPFR Library is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
-License for more details.
-
-You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
-the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-MA 02111-1307, USA. */
-
-#include "gmp.h"
-#include "gmp-impl.h"
-#include "longlong.h"
-#include "mpfr.h"
-#include "mpfr-impl.h"
-
-/* puts the mantissa of f into z, and returns 'exp' such that f = z * 2^exp
- *
- * 0 doesn't have an exponent, therefore the returned exponent in this case
- * isn't really important. We choose to return __mpfr_emin because
- * 1) it is in the exponent range [__mpfr_emin,__mpfr_emax],
- * 2) the smaller a number is (in absolute value), the smaller its
- * exponent is. In other words, the f -> exp function is monotonous
- * on nonnegative numbers.
- * Note that this is different from the C function frexp().
- */
-
-mp_exp_t
-mpfr_get_z_exp (mpz_ptr z, mpfr_srcptr f)
-{
- mp_size_t fn;
- int sh;
-
- MPFR_ASSERTN(MPFR_IS_FP(f));
-
- if (MPFR_IS_ZERO(f))
- {
- mpz_set_ui (z, 0);
- return __mpfr_emin;
- }
-
- fn = 1 + (MPFR_PREC(f) - 1) / BITS_PER_MP_LIMB;
-
- /* check whether allocated space for z is enough */
- if (ALLOC(z) < fn)
- MPZ_REALLOC(z, fn);
-
- sh = (mp_prec_t) fn * BITS_PER_MP_LIMB - MPFR_PREC(f);
- if (sh)
- mpn_rshift (PTR(z), MPFR_MANT(f), fn, sh);
- else
- MPN_COPY (PTR(z), MPFR_MANT(f), fn);
-
- SIZ(z) = fn;
-
- MPFR_ASSERTN((mp_exp_unsigned_t) MPFR_EXP(f) - MPFR_EMIN_MIN
- >= (mp_exp_unsigned_t) MPFR_PREC(f));
- return MPFR_EXP(f) - MPFR_PREC(f);
-}
diff --git a/mpfr/mul.c b/mpfr/mul.c
index 2ac3e5140..c03e95394 100644
--- a/mpfr/mul.c
+++ b/mpfr/mul.c
@@ -1,6 +1,6 @@
/* mpfr_mul -- multiply two floating-point numbers
-Copyright (C) 1999-2002 Free Software Foundation, Inc.
+Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/mul_2exp.c b/mpfr/mul_2exp.c
index 6f3ef9eb3..f22a8ff72 100644
--- a/mpfr/mul_2exp.c
+++ b/mpfr/mul_2exp.c
@@ -1,6 +1,6 @@
/* mpfr_mul_2exp -- multiply a floating-point number by a power of two
-Copyright (C) 1999, 2001 Free Software Foundation, Inc.
+Copyright 1999, 2001 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/mul_2si.c b/mpfr/mul_2si.c
index b1189242f..e33a491c0 100644
--- a/mpfr/mul_2si.c
+++ b/mpfr/mul_2si.c
@@ -1,6 +1,6 @@
/* mpfr_mul_2si -- multiply a floating-point number by a power of two
-Copyright (C) 1999, 2001 Free Software Foundation, Inc.
+Copyright 1999, 2001 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/mul_2ui.c b/mpfr/mul_2ui.c
index 64ac7c7ae..5101effa0 100644
--- a/mpfr/mul_2ui.c
+++ b/mpfr/mul_2ui.c
@@ -1,6 +1,6 @@
/* mpfr_mul_2ui -- multiply a floating-point number by a power of two
-Copyright (C) 1999, 2001 Free Software Foundation, Inc.
+Copyright 1999, 2001 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/mul_ui.c b/mpfr/mul_ui.c
index 72f9decef..1e6fdcd18 100644
--- a/mpfr/mul_ui.c
+++ b/mpfr/mul_ui.c
@@ -1,6 +1,6 @@
/* mpfr_mul_ui -- multiply a floating-point number by a machine integer
-Copyright (C) 1999-2002 Free Software Foundation, Inc.
+Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/neg.c b/mpfr/neg.c
index 1944cdab9..de3419f73 100644
--- a/mpfr/neg.c
+++ b/mpfr/neg.c
@@ -1,6 +1,6 @@
/* mpfr_neg -- change the sign of a floating-point number
-Copyright (C) 1999-2001 Free Software Foundation.
+Copyright 1999, 2000, 2001 Free Software Foundation.
This file is part of the MPFR Library.
Contributed by the Spaces project (LORIA/LIP6).
@@ -16,7 +16,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/out_str.c b/mpfr/out_str.c
index 964aa9951..ecee8470d 100644
--- a/mpfr/out_str.c
+++ b/mpfr/out_str.c
@@ -1,6 +1,6 @@
/* mpfr_out_str -- output a floating-point number to a stream
-Copyright (C) 1999, 2001 Free Software Foundation, Inc.
+Copyright 1999, 2001 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/pow.c b/mpfr/pow.c
index af4bddec7..4a2901db6 100644
--- a/mpfr/pow.c
+++ b/mpfr/pow.c
@@ -1,6 +1,6 @@
/* mpfr_pow -- power function x^y
-Copyright (C) 2001-2002 Free Software Foundation, Inc.
+Copyright 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/pow_si.c b/mpfr/pow_si.c
index 0380b2fa7..997b3960f 100644
--- a/mpfr/pow_si.c
+++ b/mpfr/pow_si.c
@@ -1,6 +1,6 @@
/* mpfr_pow_si -- power function x^y with y an unsigned int
-Copyright (C) 2001-2002 Free Software Foundation, Inc.
+Copyright 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/pow_ui.c b/mpfr/pow_ui.c
index 0badba7e4..5b033507a 100644
--- a/mpfr/pow_ui.c
+++ b/mpfr/pow_ui.c
@@ -1,7 +1,7 @@
/* mpfr_pow_ui-- compute the power of a floating-point
by a machine integer
-Copyright (C) 1999-2002 Free Software Foundation, Inc.
+Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -16,7 +16,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/print_raw.c b/mpfr/print_raw.c
index 0f127f2a1..b31a3f830 100644
--- a/mpfr/print_raw.c
+++ b/mpfr/print_raw.c
@@ -1,7 +1,7 @@
/* mpfr_print_binary -- print the internal binary representation of a
floating-point number
-Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
+Copyright 1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -16,7 +16,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/print_rnd_mode.c b/mpfr/print_rnd_mode.c
index 0daf2dc90..c09044676 100644
--- a/mpfr/print_rnd_mode.c
+++ b/mpfr/print_rnd_mode.c
@@ -1,6 +1,6 @@
/* mpfr_print_rnd_mode -- convert a given rounding mode to a string
-Copyright (C) 1999, 2001 Free Software Foundation.
+Copyright 1999, 2001, 2002 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,11 +15,10 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
-#include <stdio.h>
#include <stdlib.h>
#include "gmp.h"
#include "gmp-impl.h"
@@ -38,8 +37,7 @@ mpfr_print_rnd_mode (mp_rnd_t rnd_mode)
return ("GMP_RNDN");
case GMP_RNDZ:
return ("GMP_RNDZ");
- default:
- fprintf (stderr, "unknown rounding mode\n");
- exit (1);
}
+
+ return NULL;
}
diff --git a/mpfr/random.c b/mpfr/random.c
index 8e67922b2..12eebdb5d 100644
--- a/mpfr/random.c
+++ b/mpfr/random.c
@@ -1,6 +1,6 @@
/* mpfr_random -- generate a random floating-point number
-Copyright (C) 1999, 2001 Free Software Foundation, Inc.
+Copyright 1999, 2001 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/random2.c b/mpfr/random2.c
index 8b42a7674..12398b96e 100644
--- a/mpfr/random2.c
+++ b/mpfr/random2.c
@@ -2,7 +2,7 @@
long runs of consecutive ones and zeros in the binary representation.
Intended for testing of other MP routines.
-Copyright (C) 1999, 2001 Free Software Foundation, Inc.
+Copyright 1999, 2001 Free Software Foundation, Inc.
(Copied from the GNU MP Library.)
This file is part of the MPFR Library.
@@ -18,7 +18,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/reldiff.c b/mpfr/reldiff.c
index 66597bcf4..1984b45a7 100644
--- a/mpfr/reldiff.c
+++ b/mpfr/reldiff.c
@@ -1,6 +1,6 @@
/* mpfr_reldiff -- compute relative difference of two floating-point numbers.
-Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+Copyright 2000, 2001 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/rint.c b/mpfr/rint.c
index 05875cda1..73582513b 100644
--- a/mpfr/rint.c
+++ b/mpfr/rint.c
@@ -1,6 +1,6 @@
/* mpfr_rint -- Round to an integer.
-Copyright (C) 1999-2002 Free Software Foundation, Inc.
+Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/rnd_mode.c b/mpfr/rnd_mode.c
index eba015dc5..eb9402acf 100644
--- a/mpfr/rnd_mode.c
+++ b/mpfr/rnd_mode.c
@@ -1,6 +1,6 @@
/* mpfr_set_machine_rnd_mode -- set the rounding mode for machine floats
-Copyright (C) 1999, 2001 Free Software Foundation, Inc.
+Copyright 1999, 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,115 +15,26 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
-#ifdef TEST
+#ifdef HAVE_FENV_H
#include <stdio.h>
#include <stdlib.h>
+#include <fenv.h>
#include "gmp.h"
#include "mpfr.h"
-/* functions to set/get the machine rounding mode */
-#ifdef _ISOC9X_SOURCE
-#include <fenv.h>
-#define TONEAREST fesetround(FE_TONEAREST)
-#define TOZERO fesetround(FE_TOWARDZERO)
-#define TOINFP fesetround(FE_UPWARD)
-#define TOINFM fesetround(FE_DOWNWARD)
-#elif __mips
-#include <sys/fpu.h>
-extern int swapRM();
-#define TOZERO swapRM(ROUND_TO_ZERO)
-#define TOINFP swapRM(ROUND_TO_PLUS_INFINITY)
-#define TONEAREST swapRM(ROUND_TO_NEAREST)
-#define TOINFM swapRM(ROUND_TO_MINUS_INFINITY)
-#elif (defined (__sparc__) || defined(hpux) || defined(freebsd))
-#ifdef hpux
-#include <math.h>
-#else
-#ifdef freebsd
-#include <floatingpoint.h>
-#else
-#include <ieeefp.h>
-#endif
-#endif
-#define TOZERO fpsetround(FP_RZ)
-#define TOINFP fpsetround(FP_RP)
-#define TONEAREST fpsetround(FP_RN)
-#define TOINFM fpsetround(FP_RM)
-#elif defined (__alpha)
-#ifdef __GNUC__
-/* GCC patched include files forget to define those... */
-#define FP_RND_RZ 0
-#define FP_RND_RN 1
-#define FP_RND_RP 2
-#define FP_RND_RM 3
-#endif
-#include <float.h>
-#define TOZERO write_rnd(FP_RND_RZ)
-#define TOINFP write_rnd(FP_RND_RP)
-#define TONEAREST write_rnd(FP_RND_RN)
-#define TOINFM write_rnd(FP_RND_RM)
-#elif AIX
-/* those values should be defined in float.h but strangely are not */
-#define FP_RND_RZ 0
-#define FP_RND_RN 1
-#define FP_RND_RP 2
-#define FP_RND_RM 3
-#include <float.h>
-#define TOZERO fp_swap_rnd(FP_RND_RZ)
-#define TOINFP fp_swap_rnd(FP_RND_RP)
-#define TONEAREST fp_swap_rnd(FP_RND_RN)
-#define TOINFM fp_swap_rnd(FP_RND_RM)
-#elif sunos
-#include <floatingpoint.h>
-char *out;
-#define TOZERO ieee_flags("set","direction","tozero",&out)
-#define TOINFP ieee_flags("set","direction","positive",&out)
-#define TONEAREST ieee_flags("set","direction","nearest",&out)
-#define TOINFM ieee_flags("set","direction","negative",&out)
-#elif (defined (__powerpc__) && defined(linux))
-#include <fpu_control.h>
-#define TOZERO _FPU_SETCW(_FPU_RC_ZERO)
-#define TOINFP _FPU_SETCW(_FPU_RC_UP)
-#define TOINFM _FPU_SETCW(_FPU_RC_DOWN)
-#define TONEAREST _FPU_SETCW(_FPU_RC_NEAREST)
-#elif (defined (__i386__) || defined (__i486__) || defined (linux))
-#ifdef __CYGWIN32__ /* no fpu_control.h under Cygnus */
-#define _FPU_EXTENDED 0x300
-#define _FPU_DOUBLE 0x200
-#define _FPU_DEFAULT 0x137f
-#define _FPU_RC_NEAREST 0x0
-#define _FPU_RC_DOWN 0x400
-#define _FPU_RC_UP 0x800
-#define _FPU_RC_ZERO 0xC00
-#else
-#include <fpu_control.h>
-#endif
-#if defined(LIBC211) || defined(__CYGWIN32__)
-#define __setfpucw(cw) __asm__ ("fldcw %0" : : "m" (cw))
-#endif
-/* be careful to put Precision control bits
- to round to double precision instead of the
- default (round to extended precision) */
-#define _fpu_ieee ((_FPU_DEFAULT & (~_FPU_EXTENDED)) | _FPU_DOUBLE)
-#define TOZERO __setfpucw(_fpu_ieee | _FPU_RC_ZERO)
-#define TOINFP __setfpucw(_fpu_ieee | _FPU_RC_UP)
-#define TOINFM __setfpucw(_fpu_ieee | _FPU_RC_DOWN)
-#define TONEAREST __setfpucw(_fpu_ieee)
-#endif
-
/* sets the machine rounding mode to the value rnd_mode */
void
mpfr_set_machine_rnd_mode (mp_rnd_t rnd_mode)
{
switch (rnd_mode) {
- case GMP_RNDN: TONEAREST; break;
- case GMP_RNDZ: TOZERO; break;
- case GMP_RNDU: TOINFP; break;
- case GMP_RNDD: TOINFM; break;
+ case GMP_RNDN: fesetround(FE_TONEAREST); break;
+ case GMP_RNDZ: fesetround(FE_TOWARDZERO); break;
+ case GMP_RNDU: fesetround(FE_UPWARD); break;
+ case GMP_RNDD: fesetround(FE_DOWNWARD); break;
default: fprintf(stderr, "invalid rounding mode\n"); exit(1);
}
}
diff --git a/mpfr/round_prec.c b/mpfr/round_prec.c
index e0228d87e..98f80e417 100644
--- a/mpfr/round_prec.c
+++ b/mpfr/round_prec.c
@@ -1,7 +1,7 @@
/* mpfr_round_raw_generic, mpfr_round_raw2, mpfr_round_raw, mpfr_round_prec,
mpfr_can_round, mpfr_can_round_raw -- various rounding functions
-Copyright (C) 1999-2002 Free Software Foundation, Inc.
+Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -16,7 +16,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/save_expo.c b/mpfr/save_expo.c
index fe451c548..a4971dea1 100644
--- a/mpfr/save_expo.c
+++ b/mpfr/save_expo.c
@@ -1,6 +1,6 @@
/* Save/restore the minimum and maximum exponents.
-Copyright (C) 2001 Free Software Foundation, Inc.
+Copyright 2001 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/set.c b/mpfr/set.c
index de78a476a..b3823b84d 100644
--- a/mpfr/set.c
+++ b/mpfr/set.c
@@ -1,6 +1,6 @@
/* mpfr_set -- copy of a floating-point number
-Copyright (C) 1999, 2001 Free Software Foundation.
+Copyright 1999, 2001 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/set_d.c b/mpfr/set_d.c
index 2c7ff2e16..6514f9477 100644
--- a/mpfr/set_d.c
+++ b/mpfr/set_d.c
@@ -1,7 +1,7 @@
-/* mpfr_set_d, mpfr_get_d -- convert a multiple precision floating-point number
- from/to a machine double precision float
+/* mpfr_set_d -- convert a machine double precision float to
+ a multiple precision floating-point number
-Copyright (C) 1999-2002 Free Software Foundation, Inc.
+Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -16,11 +16,10 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
-#include <float.h>
#include "gmp.h"
#include "gmp-impl.h"
#include "longlong.h"
@@ -35,12 +34,7 @@ MA 02111-1307, USA. */
#define MPFR_LIMBS_PER_DOUBLE 4
#endif
-static int __mpfr_extract_double _PROTO ((mp_ptr, double, int));
-static double __mpfr_scale2 _PROTO ((double, int));
-
-#define NaN (0./0.) /* ensures a machine-independent NaN */
-#define Infp (1/0.)
-#define Infm (-1/0.)
+static int __mpfr_extract_double _PROTO ((mp_ptr, double));
/* Included from gmp-2.0.2, patched to support denorms */
@@ -53,7 +47,7 @@ static double __mpfr_scale2 _PROTO ((double, int));
#endif
static int
-__mpfr_extract_double (mp_ptr rp, double d, int e)
+__mpfr_extract_double (mp_ptr rp, double d)
/* e=0 iff BITS_PER_MP_LIMB=32 and rp has only one limb */
{
long exp;
@@ -73,9 +67,6 @@ __mpfr_extract_double (mp_ptr rp, double d, int e)
if (d == 0.0)
{
rp[0] = 0;
-#if BITS_PER_MP_LIMB == 32
- if (e) rp[1] = 0;
-#endif
return 0;
}
@@ -95,13 +86,14 @@ __mpfr_extract_double (mp_ptr rp, double d, int e)
manl = x.s.manl << 11;
#endif
}
- else
+ else /* denormalized number */
{
#if BITS_PER_MP_LIMB == 64
manl = ((mp_limb_t) x.s.manh << 43) | ((mp_limb_t) x.s.manl << 11);
#else
- manh = (x.s.manh << 11) | (x.s.manl >> 21);
- manl = x.s.manl << 11;
+ manh = (x.s.manh << 11) /* high 21 bits */
+ | (x.s.manl >> 21); /* middle 11 bits */
+ manl = x.s.manl << 11; /* low 21 bits */
#endif
}
}
@@ -154,85 +146,22 @@ __mpfr_extract_double (mp_ptr rp, double d, int e)
if (exp) exp = (unsigned) exp - 1022; else exp = -1021;
#if BITS_PER_MP_LIMB == 64
- rp[0] = manl;
+ rp[0] = manl;
#else
- if (e) {
- rp[1] = manh;
- rp[0] = manl;
- }
- else {
- rp[0] = manh;
- }
+ rp[1] = manh;
+ rp[0] = manl;
#endif
return exp;
}
/* End of part included from gmp-2.0.2 */
-/* Part included from gmp temporary releases and modified */
-static double
-__mpfr_scale2 (double d, int exp)
-{
-#if _GMP_IEEE_FLOATS
- {
- union ieee_double_extract x;
-
- if (exp < -2099)
- return 0.0 * d; /* 0 with the correct sign */
-
- x.d = d;
- if (exp >= 2047 || exp + x.s.exp >= 2047)
- {
- /* Return +-infinity */
- x.s.exp = 2047;
- x.s.manl = x.s.manh = 0;
- }
- else if (exp + x.s.exp < 1)
- {
- exp += x.s.exp;
- if (exp <= -52)
- return 0.0 * d; /* 0 with the correct sign */
- x.s.exp = 1; /* smallest exponent (biased) */
- x.d *= __mpfr_scale2(1.0, exp - 1);
- }
- else
- {
- x.s.exp += exp;
- }
- return x.d;
- }
-#else
- {
- double factor;
-
- if (exp < 0)
- {
- factor = 0.5;
- exp = -exp;
- }
- else
- {
- factor = 2.0;
- }
- while (exp != 0)
- {
- if ((exp & 1) != 0)
- d *= factor;
- exp >>= 1;
- factor *= factor;
- }
- return r;
- }
-#endif
-}
-
-/* End of part included from gmp */
int
mpfr_set_d (mpfr_ptr r, double d, mp_rnd_t rnd_mode)
{
- int signd, sizer, sizetmp, inexact;
- unsigned int cnt;
+ int signd, sizetmp, inexact;
+ unsigned int cnt, k;
mpfr_ptr tmp;
TMP_DECL(marker);
@@ -266,9 +195,7 @@ mpfr_set_d (mpfr_ptr r, double d, mp_rnd_t rnd_mode)
return 0; /* infinity is exact */
}
- sizer = (MPFR_PREC(r) - 1) / BITS_PER_MP_LIMB + 1;
-
- /* warning: don't use tmp=r here, even if sizer >= MPFR_LIMBS_PER_DOUBLE,
+ /* warning: don't use tmp=r here, even if SIZE(r) >= MPFR_LIMBS_PER_DOUBLE,
since PREC(r) may be different from PREC(tmp), and then both variables
would have same precision in the mpfr_set4 call below. */
tmp = (mpfr_ptr) TMP_ALLOC(sizeof(mpfr_t));
@@ -280,91 +207,25 @@ mpfr_set_d (mpfr_ptr r, double d, mp_rnd_t rnd_mode)
signd = (d < 0) ? -1 : 1;
d = ABS (d);
- MPFR_EXP(tmp) = __mpfr_extract_double (MPFR_MANT(tmp), d, 1);
+ MPFR_EXP(tmp) = __mpfr_extract_double (MPFR_MANT(tmp), d);
+
+ /* determine number k of zero high limbs */
+ for (k = 0; k < sizetmp && MPFR_MANT(tmp)[sizetmp - 1 - k] == 0; k++);
- count_leading_zeros(cnt, MPFR_MANT(tmp)[sizetmp - 1]);
+ count_leading_zeros (cnt, MPFR_MANT(tmp)[sizetmp - 1 - k]);
if (cnt)
- mpn_lshift (MPFR_MANT(tmp), MPFR_MANT(tmp), sizetmp, cnt);
+ mpn_lshift (MPFR_MANT(tmp) + k, MPFR_MANT(tmp), sizetmp - k, cnt);
+ else if (k)
+ MPN_COPY (MPFR_MANT(tmp) + k, MPFR_MANT(tmp), sizetmp - k);
+ if (k)
+ MPN_ZERO (MPFR_MANT(tmp), k);
- MPFR_EXP(tmp) -= cnt;
+ MPFR_EXP(tmp) -= cnt + k * BITS_PER_MP_LIMB;
/* tmp is exact since PREC(tmp)=53 */
- inexact = mpfr_set4(r, tmp, rnd_mode, signd);
+ inexact = mpfr_set4 (r, tmp, rnd_mode, signd);
TMP_FREE(marker);
return inexact;
}
-
-double
-mpfr_get_d2 (mpfr_srcptr src, mp_exp_t e)
-{
- double d;
- mpfr_t tmp;
- int s, negative;
-
- if (MPFR_IS_NAN(src))
- return NaN;
-
- negative = MPFR_SIGN(src) < 0;
-
- if (MPFR_IS_INF(src))
- return negative ? Infm : Infp;
-
- if (MPFR_IS_ZERO(src))
- return negative ? -0.0 : 0.0;
-
- if (e < -1076)
- { /* Simulate the underflow with the current IEEE rounding mode. */
- d = DBL_MIN;
- d *= negative ? -DBL_MIN : DBL_MIN;
- /* -> double precision forced by the affectation */
- }
- else if (e > 1024)
- { /* Simulate the overflow with the current IEEE rounding mode. */
- d = DBL_MAX;
- d *= negative ? -2 : 2;
- }
- else
- {
- mp_ptr tp;
- mp_size_t np, i;
- double r;
-
- mpfr_save_emin_emax();
-
- /* Truncate src to 54 bits
- * --> rounding bit stored to the 54th bit
- * --> sticky bit stored to variable s */
- mpfr_init2(tmp, 54);
- s = mpfr_set(tmp, src, GMP_RNDZ);
- MPFR_ASSERTN(MPFR_IS_FP(tmp) && MPFR_NOTZERO(tmp));
-
- /* Warning: the rounding may still be incorrect in the rounding
- to the nearest mode when the result is a subnormal because of
- a double rounding (-> 53 bits -> final precision). */
- tp = MPFR_MANT(tmp);
- d = (tp[0] & (MP_LIMB_T_MAX << 11)) / MP_BASE_AS_DOUBLE;
- np = (MPFR_PREC(tmp) - 1) / BITS_PER_MP_LIMB;
- for (i = 1; i <= np; i++)
- d = (d + tp[i]) / MP_BASE_AS_DOUBLE;
- /* d is the mantissa (between 1/2 and 1) of the argument truncated
- to 53 bits */
- r = (((tp[0] >> 9) & 2) + (s != 0)) * (DBL_EPSILON / 8.0);
- d += r; /* double precision forced by the affectation */
- d = __mpfr_scale2(d, e);
- if (negative)
- d = -d;
-
- mpfr_clear(tmp);
- mpfr_restore_emin_emax();
- }
-
- return d;
-}
-
-double
-mpfr_get_d (mpfr_srcptr src)
-{
- return mpfr_get_d2 (src, MPFR_EXP(src));
-}
diff --git a/mpfr/set_dfl_prec.c b/mpfr/set_dfl_prec.c
index d24f1c037..13e3ed3cc 100644
--- a/mpfr/set_dfl_prec.c
+++ b/mpfr/set_dfl_prec.c
@@ -1,6 +1,6 @@
/* mpfr_set_default_prec, mpfr_get_default_prec -- set/get default precision
-Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
+Copyright 1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/set_f.c b/mpfr/set_f.c
index de4768a93..3aeb10fce 100644
--- a/mpfr/set_f.c
+++ b/mpfr/set_f.c
@@ -1,6 +1,6 @@
/* mpfr_set_f -- set a MPFR number from a GNU MPF number
-Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
+Copyright 1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/set_prc_raw.c b/mpfr/set_prc_raw.c
index 0f893d59e..0a054a407 100644
--- a/mpfr/set_prc_raw.c
+++ b/mpfr/set_prc_raw.c
@@ -1,6 +1,6 @@
/* mpfr_set_prec_raw -- reset the precision of a floating-point number
-Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+Copyright 2000, 2001 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/set_prec.c b/mpfr/set_prec.c
index f6591c0f2..5b162b364 100644
--- a/mpfr/set_prec.c
+++ b/mpfr/set_prec.c
@@ -1,6 +1,6 @@
/* mpfr_set_prec -- reset the precision of a floating-point number
-Copyright (C) 1999, 2001 Free Software Foundation, Inc.
+Copyright 1999, 2001 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/set_q.c b/mpfr/set_q.c
index 5a73b4d66..54a7a9e2f 100644
--- a/mpfr/set_q.c
+++ b/mpfr/set_q.c
@@ -1,6 +1,6 @@
/* mpfr_set_q -- set a floating-point number from a multiple-precision rational
-Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+Copyright 2000, 2001 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,14 +15,14 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
#include "gmp.h"
-#include "gmp-impl.h"
#include "mpfr.h"
#include "mpfr-impl.h"
+#include "gmp-impl.h"
#include "longlong.h"
/* set f to the rational q */
@@ -51,3 +51,6 @@ mpfr_set_q (mpfr_ptr f, mpq_srcptr q, mp_rnd_t rnd)
mpfr_clear (d);
MPFR_RET(inexact);
}
+
+
+
diff --git a/mpfr/set_rnd.c b/mpfr/set_rnd.c
index 7948ba36a..15ae17b26 100644
--- a/mpfr/set_rnd.c
+++ b/mpfr/set_rnd.c
@@ -1,6 +1,6 @@
/* mpfr_set_default_rounding_mode -- set the default rounding mode
-Copyright (C) 1999, 2001 Free Software Foundation, Inc.
+Copyright 1999, 2001 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/set_si.c b/mpfr/set_si.c
index 8690e6b8f..9539101c3 100644
--- a/mpfr/set_si.c
+++ b/mpfr/set_si.c
@@ -1,6 +1,6 @@
/* mpfr_set_si -- set a MPFR number from a machine signed integer
-Copyright (C) 1999-2001 Free Software Foundation.
+Copyright 1999, 2000, 2001 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -49,6 +49,9 @@ mpfr_set_si (mpfr_ptr x, long i, mp_rnd_t rnd_mode)
xp[xn] = ai << cnt;
/* don't forget to put zero in lower limbs */
MPN_ZERO(xp, xn);
+ /* set sign */
+ if ((i < 0) ^ (MPFR_SIGN(x) < 0))
+ MPFR_CHANGE_SIGN(x);
MPFR_EXP(x) = nbits = BITS_PER_MP_LIMB - cnt;
inex = mpfr_check_range(x, rnd_mode);
@@ -67,15 +70,12 @@ mpfr_set_si (mpfr_ptr x, long i, mp_rnd_t rnd_mode)
mp_exp_t exp = MPFR_EXP(x);
if (exp == __mpfr_emax)
- return mpfr_set_overflow(x, rnd_mode, (ai < 0 ? -1 : 1));
+ return mpfr_set_overflow(x, rnd_mode, (i < 0 ? -1 : 1));
MPFR_EXP(x)++;
xp[xn] = MP_LIMB_T_HIGHBIT;
}
}
- if ((i < 0) ^ (MPFR_SIGN(x) < 0))
- MPFR_CHANGE_SIGN(x);
-
MPFR_RET(inex);
}
diff --git a/mpfr/set_str.c b/mpfr/set_str.c
index d4a6b686d..cd39d44b8 100644
--- a/mpfr/set_str.c
+++ b/mpfr/set_str.c
@@ -1,6 +1,6 @@
/* mpfr_set_str -- set a floating-point number from a string
-Copyright (C) 2000-2002 Free Software Foundation, Inc.
+Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/set_str_raw.c b/mpfr/set_str_raw.c
index d76f502d8..d44235c31 100644
--- a/mpfr/set_str_raw.c
+++ b/mpfr/set_str_raw.c
@@ -1,6 +1,6 @@
/* mpfr_set_str_raw -- set a floating-point number from a binary string
-Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
+Copyright 1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -40,8 +40,8 @@ mpfr_set_str_raw (mpfr_ptr x, char *str)
long expn = 0, e; char *endstr2;
xp = MPFR_MANT(x);
- xsize = 1 + (MPFR_PREC(x)-1)/BITS_PER_MP_LIMB;
- alloc = (strlen(str)+1) * sizeof(char);
+ xsize = 1 + (MPFR_PREC(x) - 1) / BITS_PER_MP_LIMB;
+ alloc = (strlen(str) + 1) * sizeof(char);
if (*str == '-')
{
@@ -102,7 +102,7 @@ mpfr_set_str_raw (mpfr_ptr x, char *str)
MPFR_SET_ZERO(x);
}
else {
- l = (l-1) / BITS_PER_MP_LIMB + 1;
+ l = (l - 1) / BITS_PER_MP_LIMB + 1;
str2 = str0;
if (l > xsize) {
@@ -115,7 +115,7 @@ mpfr_set_str_raw (mpfr_ptr x, char *str)
{
j = 0;
xp[xsize - k] = 0;
- while (str2<endstr2 && j < BITS_PER_MP_LIMB)
+ while ((str2 < endstr2) && (j < BITS_PER_MP_LIMB))
{
xp[xsize - k] = (xp[xsize - k] << 1) + (*str2 - '0');
str2++; j++;
@@ -129,7 +129,8 @@ mpfr_set_str_raw (mpfr_ptr x, char *str)
if (cnt) mpn_lshift(xp, xp, xsize, cnt);
MPFR_EXP(x) = expn - cnt;
- MPFR_SIZE(x) = xsize; if (negative) MPFR_CHANGE_SIGN(x);
+ if (MPFR_ISNEG(x) != negative)
+ MPFR_CHANGE_SIGN(x);
}
(*__gmp_free_func) (str0, alloc);
diff --git a/mpfr/set_ui.c b/mpfr/set_ui.c
index e14b29278..051c188e7 100644
--- a/mpfr/set_ui.c
+++ b/mpfr/set_ui.c
@@ -1,6 +1,6 @@
/* mpfr_set_ui -- set a MPFR number from a machine unsigned integer
-Copyright (C) 1999-2001 Free Software Foundation.
+Copyright 1999, 2000, 2001 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/set_z.c b/mpfr/set_z.c
index 5f4ffeb5e..3a68d6c15 100644
--- a/mpfr/set_z.c
+++ b/mpfr/set_z.c
@@ -1,6 +1,6 @@
/* mpfr_set_z -- set a floating-point number from a multiple-precision integer
-Copyright (C) 1999-2002 Free Software Foundation, Inc.
+Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/sin.c b/mpfr/sin.c
index 20db37436..e45be0329 100644
--- a/mpfr/sin.c
+++ b/mpfr/sin.c
@@ -1,6 +1,6 @@
/* mpfr_sin -- sine of a floating-point number
-Copyright (C) 2001-2002 Free Software Foundation, Inc.
+Copyright 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/sin_cos.c b/mpfr/sin_cos.c
index ef56d3732..d5bde86cd 100644
--- a/mpfr/sin_cos.c
+++ b/mpfr/sin_cos.c
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -97,5 +97,3 @@ mpfr_sin_cos (mpfr_ptr y, mpfr_ptr z, mpfr_srcptr x, mp_rnd_t rnd_mode)
return inexact; /* inexact */
}
-
-
diff --git a/mpfr/sinh.c b/mpfr/sinh.c
index e296891f8..62dc1a84d 100644
--- a/mpfr/sinh.c
+++ b/mpfr/sinh.c
@@ -1,6 +1,6 @@
/* mpfr_sinh -- hyperbolic sine
-Copyright (C) 2001-2002 Free Software Foundation, Inc.
+Copyright 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/sqrt.c b/mpfr/sqrt.c
index 1169a8827..09153f3ea 100644
--- a/mpfr/sqrt.c
+++ b/mpfr/sqrt.c
@@ -1,6 +1,6 @@
/* mpfr_sqrt -- square root of a floating-point number
-Copyright (C) 1999-2002 Free Software Foundation, Inc.
+Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -40,9 +40,7 @@ mpfr_sqrt (mpfr_ptr r, mpfr_srcptr u, mp_rnd_t rnd_mode)
unsigned long cc = 0;
int can_round = 0;
- TMP_DECL(marker0);
- {
- TMP_DECL (marker);
+ TMP_DECL(marker);
if (MPFR_IS_NAN(u))
{
@@ -107,7 +105,7 @@ mpfr_sqrt (mpfr_ptr r, mpfr_srcptr u, mp_rnd_t rnd_mode)
to shift then.
*/
- TMP_MARK(marker0);
+ TMP_MARK(marker);
if (odd_exp_u) /* Shift u one bit to the right */
{
if (MPFR_PREC(u) & (BITS_PER_MP_LIMB - 1))
@@ -132,7 +130,6 @@ mpfr_sqrt (mpfr_ptr r, mpfr_srcptr u, mp_rnd_t rnd_mode)
do
{
- TMP_MARK (marker);
err = rsize * BITS_PER_MP_LIMB;
if (rsize < usize)
@@ -184,7 +181,6 @@ mpfr_sqrt (mpfr_ptr r, mpfr_srcptr u, mp_rnd_t rnd_mode)
#ifdef DEBUG
printf("Increasing the precision.\n");
#endif
- TMP_FREE(marker);
}
}
while (!can_round && (rsize < 2*usize) && (rsize += 2) && (rrsize++));
@@ -271,7 +267,7 @@ mpfr_sqrt (mpfr_ptr r, mpfr_srcptr u, mp_rnd_t rnd_mode)
MPFR_EXP(r)++;
}
- fin:
+ fin:
rsize = rrsize;
rrsize = (MPFR_PREC(r) - 1)/BITS_PER_MP_LIMB + 1;
MPN_COPY(MPFR_MANT(r), rp + rsize - rrsize, rrsize);
@@ -281,8 +277,6 @@ mpfr_sqrt (mpfr_ptr r, mpfr_srcptr u, mp_rnd_t rnd_mode)
(BITS_PER_MP_LIMB -
(MPFR_PREC(r) & (BITS_PER_MP_LIMB - 1)))) - 1);
- TMP_FREE (marker);
- }
- TMP_FREE(marker0);
+ TMP_FREE(marker);
return inexact;
}
diff --git a/mpfr/sqrt_ui.c b/mpfr/sqrt_ui.c
index e72f0227a..21cba67fa 100644
--- a/mpfr/sqrt_ui.c
+++ b/mpfr/sqrt_ui.c
@@ -1,6 +1,6 @@
/* mpfr_sqrt_ui -- square root of a machine integer
-Copyright (C) 2000-2002 Free Software Foundation, Inc.
+Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/sub.c b/mpfr/sub.c
index 95f05c9b6..c03973d52 100644
--- a/mpfr/sub.c
+++ b/mpfr/sub.c
@@ -1,6 +1,6 @@
/* mpfr_sub -- subtract two floating-point numbers
-Copyright (C) 2001 Free Software Foundation.
+Copyright 2001 Free Software Foundation.
Contributed by the Spaces project, INRIA Lorraine.
This file is part of the MPFR Library.
@@ -16,7 +16,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/sub1.c b/mpfr/sub1.c
index 99e119d8e..781773255 100644
--- a/mpfr/sub1.c
+++ b/mpfr/sub1.c
@@ -1,6 +1,6 @@
/* mpfr_sub1 -- internal function to perform a "real" subtraction
-Copyright (C) 2001 Free Software Foundation.
+Copyright 2001 Free Software Foundation.
Contributed by the Spaces project, INRIA Lorraine.
This file is part of the MPFR Library.
@@ -16,7 +16,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/sub_one_ulp.c b/mpfr/sub_one_ulp.c
index 3d229eb0c..df1c3d808 100644
--- a/mpfr/sub_one_ulp.c
+++ b/mpfr/sub_one_ulp.c
@@ -1,6 +1,6 @@
/* mpfr_sub_one_ulp -- subtract one unit in last place
-Copyright (C) 1999, 2001 Free Software Foundation, Inc.
+Copyright 1999, 2001 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/sub_ui.c b/mpfr/sub_ui.c
index ce4b0bc63..3085e89be 100644
--- a/mpfr/sub_ui.c
+++ b/mpfr/sub_ui.c
@@ -1,6 +1,6 @@
/* mpfr_sub_ui -- subtract a floating-point number and a machine integer
-Copyright (C) 2000-2002 Free Software Foundation, Inc.
+Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/swap.c b/mpfr/swap.c
index 9dd7d4e27..af4b6970c 100644
--- a/mpfr/swap.c
+++ b/mpfr/swap.c
@@ -1,6 +1,6 @@
/* mpfr_swap (U, V) -- Swap U and V.
-Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+Copyright 2000, 2001 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/tan.c b/mpfr/tan.c
index 3947cdd26..5a1f8d10d 100644
--- a/mpfr/tan.c
+++ b/mpfr/tan.c
@@ -1,6 +1,6 @@
/* mpfr_tan -- tangent of a floating-point number
-Copyright (C) 2001-2002 Free Software Foundation, Inc.
+Copyright 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/tanh.c b/mpfr/tanh.c
index 13996358c..a7908a25f 100644
--- a/mpfr/tanh.c
+++ b/mpfr/tanh.c
@@ -1,6 +1,6 @@
/* mpfr_tanh -- hyperbolic tangent
-Copyright (C) 2001-2002 Free Software Foundation.
+Copyright 2001, 2002 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/tests/Makefile.am b/mpfr/tests/Makefile.am
index 0465614ce..bc20938b4 100644
--- a/mpfr/tests/Makefile.am
+++ b/mpfr/tests/Makefile.am
@@ -22,7 +22,7 @@
AUTOMAKE_OPTIONS = gnu no-dependencies $(top_builddir)/ansi2knr
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/mpfr
-CFLAGS = @CFLAGS@ $(CFLAGS_IEEE_WITH_INEXACT)
+CFLAGS = @CFLAGS@ $(MPFR_CFLAGS)
LDADD = ../libmpfr.a $(top_builddir)/libgmp.la $(LIBM)
if WANT_MPFR
diff --git a/mpfr/tests/Makefile.in b/mpfr/tests/Makefile.in
index 78a100bcc..9247afade 100644
--- a/mpfr/tests/Makefile.in
+++ b/mpfr/tests/Makefile.in
@@ -84,7 +84,6 @@ BITS_PER_MP_LIMB = @BITS_PER_MP_LIMB@
CALLING_CONVENTIONS_OBJS = @CALLING_CONVENTIONS_OBJS@
CC = @CC@
CCAS = @CCAS@
-CFLAGS_IEEE_WITH_INEXACT = @CFLAGS_IEEE_WITH_INEXACT@
CPP = @CPP@
CXX = @CXX@
CXXCPP = @CXXCPP@
@@ -111,6 +110,7 @@ LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
M4 = @M4@
MAINT = @MAINT@
+MPFR_CFLAGS = @MPFR_CFLAGS@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
@@ -137,7 +137,7 @@ mpn_objs_in_libmp = @mpn_objs_in_libmp@
AUTOMAKE_OPTIONS = gnu no-dependencies $(top_builddir)/ansi2knr
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/mpfr
-CFLAGS = @CFLAGS@ $(CFLAGS_IEEE_WITH_INEXACT)
+CFLAGS = @CFLAGS@ $(MPFR_CFLAGS)
LDADD = ../libmpfr.a $(top_builddir)/libgmp.la $(LIBM)
@WANT_MPFR_TRUE@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
diff --git a/mpfr/tests/reuse.c b/mpfr/tests/reuse.c
index a1a27ca7c..2f2024d90 100644
--- a/mpfr/tests/reuse.c
+++ b/mpfr/tests/reuse.c
@@ -1,6 +1,6 @@
/* Test file for in-place operations.
-Copyright (C) 2000, 2001, 2002 Free Software Foundation.
+Copyright 2000, 2001, 2002 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -25,7 +25,9 @@ MA 02111-1307, USA. */
#include "mpfr.h"
#include "mpfr-impl.h"
-void (*testfunc) _PROTO (()) = NULL;
+typedef void (*fct_t)();
+fct_t testfunc;
+
void test3 _PROTO ((char *, mp_prec_t, mp_rnd_t));
void test4 _PROTO ((char *, mp_prec_t, mp_rnd_t));
void test3a _PROTO ((char *, mp_prec_t, mp_rnd_t));
@@ -61,16 +63,16 @@ test3 (char *foo, mp_prec_t prec, mp_rnd_t rnd)
/* for each variable, consider each of the following 6 possibilities:
NaN, +Infinity, -Infinity, +0, -0 or a random number */
for (i=0; i<36; i++) {
- if (i%6==0) MPFR_SET_NAN(ref2);
- if (i%6==1) mpfr_set_d (ref2, 1.0/0.0, GMP_RNDN);
- if (i%6==2) mpfr_set_d (ref2, -1.0/0.0, GMP_RNDN);
+ if (i%6==0) mpfr_set_nan (ref2);
+ if (i%6==1) mpfr_set_inf (ref2, 1);
+ if (i%6==2) mpfr_set_inf (ref2, -1);
if (i%6==3) mpfr_set_d (ref2, 0.0, GMP_RNDN);
if (i%6==4) mpfr_set_d (ref2, -0.0, GMP_RNDN);
if (i%6==5) mpfr_random (ref2);
- if (i/6==0) MPFR_SET_NAN(ref3);
- if (i/6==1) mpfr_set_d (ref3, 1.0/0.0, GMP_RNDN);
- if (i/6==2) mpfr_set_d (ref3, -1.0/0.0, GMP_RNDN);
+ if (i/6==0) mpfr_set_nan (ref3);
+ if (i/6==1) mpfr_set_inf (ref3, 1);
+ if (i/6==2) mpfr_set_inf (ref3, -1);
if (i/6==3) mpfr_set_d (ref3, 0.0, GMP_RNDN);
if (i/6==4) mpfr_set_d (ref3, -0.0, GMP_RNDN);
if (i/6==5) mpfr_random (ref3);
@@ -84,9 +86,9 @@ test3 (char *foo, mp_prec_t prec, mp_rnd_t rnd)
if (mpfr_compare (res1, ref1)) {
fprintf (stderr, "Error for %s(a, a, c) for a=%e, c=%e\n", foo,
- mpfr_get_d (ref2), mpfr_get_d (ref3));
- fprintf (stderr, "expected %e, got %e\n", mpfr_get_d (ref1),
- mpfr_get_d (res1));
+ mpfr_get_d1 (ref2), mpfr_get_d1 (ref3));
+ fprintf (stderr, "expected %e, got %e\n", mpfr_get_d1 (ref1),
+ mpfr_get_d1 (res1));
exit (1);
}
@@ -95,9 +97,9 @@ test3 (char *foo, mp_prec_t prec, mp_rnd_t rnd)
testfunc (res1, ref2, res1, rnd);
if (mpfr_compare (res1, ref1)) {
fprintf (stderr, "Error for %s(a, b, a) for b=%e, a=%e\n", foo,
- mpfr_get_d (ref2), mpfr_get_d (ref3));
- fprintf (stderr, "expected %e, got %e\n", mpfr_get_d (ref1),
- mpfr_get_d (res1));
+ mpfr_get_d1 (ref2), mpfr_get_d1 (ref3));
+ fprintf (stderr, "expected %e, got %e\n", mpfr_get_d1 (ref1),
+ mpfr_get_d1 (res1));
exit (1);
}
@@ -109,9 +111,9 @@ test3 (char *foo, mp_prec_t prec, mp_rnd_t rnd)
if (mpfr_compare (res1, ref1)) {
fprintf (stderr, "Error for %s(a, a, a) for a=%e\n", foo,
- mpfr_get_d (ref2));
- fprintf (stderr, "expected %e, got %e\n", mpfr_get_d (ref1),
- mpfr_get_d (res1));
+ mpfr_get_d1 (ref2));
+ fprintf (stderr, "expected %e, got %e\n", mpfr_get_d1 (ref1),
+ mpfr_get_d1 (res1));
exit (1);
}
}
@@ -145,9 +147,9 @@ test4 (char *foo, mp_prec_t prec, mp_rnd_t rnd)
{
MPFR_CLEAR_FLAGS(op1);
- if (i==0) MPFR_SET_NAN(op1);
- if (i==1) mpfr_set_d (op1, 1.0/0.0, GMP_RNDN);
- if (i==2) mpfr_set_d (op1, -1.0/0.0, GMP_RNDN);
+ if (i==0) mpfr_set_nan (op1);
+ if (i==1) mpfr_set_inf (op1, 1);
+ if (i==2) mpfr_set_inf (op1, -1);
if (i==3) mpfr_set_d (op1, 0.0, GMP_RNDN);
if (i==4) mpfr_set_d (op1, -0.0, GMP_RNDN);
if (i==5) mpfr_random (op1);
@@ -156,9 +158,9 @@ test4 (char *foo, mp_prec_t prec, mp_rnd_t rnd)
{
MPFR_CLEAR_FLAGS(op2);
- if (j==0) MPFR_SET_NAN(op2);
- if (j==1) mpfr_set_d (op2, 1.0/0.0, GMP_RNDN);
- if (j==2) mpfr_set_d (op2, -1.0/0.0, GMP_RNDN);
+ if (j==0) mpfr_set_nan (op2);
+ if (j==1) mpfr_set_inf (op2, 1);
+ if (j==2) mpfr_set_inf (op2, -1);
if (j==3) mpfr_set_d (op2, 0.0, GMP_RNDN);
if (j==4) mpfr_set_d (op2, -0.0, GMP_RNDN);
if (j==5) mpfr_random (op2);
@@ -167,9 +169,9 @@ test4 (char *foo, mp_prec_t prec, mp_rnd_t rnd)
{
MPFR_CLEAR_FLAGS(op3);
- if (k==0) MPFR_SET_NAN(op3);
- if (k==1) mpfr_set_d (op3, 1.0/0.0, GMP_RNDN);
- if (k==2) mpfr_set_d (op3, -1.0/0.0, GMP_RNDN);
+ if (k==0) mpfr_set_nan (op3);
+ if (k==1) mpfr_set_inf (op3, 1);
+ if (k==2) mpfr_set_inf (op3, -1);
if (k==3) mpfr_set_d (op3, 0.0, GMP_RNDN);
if (k==4) mpfr_set_d (op3, -0.0, GMP_RNDN);
if (k==5) mpfr_random (op3);
@@ -186,9 +188,9 @@ test4 (char *foo, mp_prec_t prec, mp_rnd_t rnd)
fprintf (stderr,
"Error for %s(a, a, b, c) for a=%e, b=%e, c=%e\n",
foo,
- mpfr_get_d (op1), mpfr_get_d (op2), mpfr_get_d (op3));
- fprintf (stderr, "expected %e, got %e\n", mpfr_get_d (ref),
- mpfr_get_d (res));
+ mpfr_get_d1 (op1), mpfr_get_d1 (op2), mpfr_get_d1 (op3));
+ fprintf (stderr, "expected %e, got %e\n", mpfr_get_d1 (ref),
+ mpfr_get_d1 (res));
exit (1);
}
@@ -201,9 +203,9 @@ test4 (char *foo, mp_prec_t prec, mp_rnd_t rnd)
fprintf (stderr,
"Error for %s(b, a, b, c) for a=%e, b=%e, c=%e\n",
foo,
- mpfr_get_d (op1), mpfr_get_d (op2), mpfr_get_d (op3));
- fprintf (stderr, "expected %e, got %e\n", mpfr_get_d (ref),
- mpfr_get_d (res));
+ mpfr_get_d1 (op1), mpfr_get_d1 (op2), mpfr_get_d1 (op3));
+ fprintf (stderr, "expected %e, got %e\n", mpfr_get_d1 (ref),
+ mpfr_get_d1 (res));
exit (1);
}
@@ -216,9 +218,9 @@ test4 (char *foo, mp_prec_t prec, mp_rnd_t rnd)
fprintf (stderr,
"Error for %s(c, a, b, c) for a=%e, b=%e, c=%e\n",
foo,
- mpfr_get_d (op1), mpfr_get_d (op2), mpfr_get_d (op3));
- fprintf (stderr, "expected %e, got %e\n", mpfr_get_d (ref),
- mpfr_get_d (res));
+ mpfr_get_d1 (op1), mpfr_get_d1 (op2), mpfr_get_d1 (op3));
+ fprintf (stderr, "expected %e, got %e\n", mpfr_get_d1 (ref),
+ mpfr_get_d1 (res));
exit (1);
}
@@ -231,9 +233,9 @@ test4 (char *foo, mp_prec_t prec, mp_rnd_t rnd)
fprintf (stderr,
"Error for %s(a, a, a, c) for a=%e, a=%e, c=%e\n",
foo,
- mpfr_get_d (op1), mpfr_get_d (op2), mpfr_get_d (op3));
- fprintf (stderr, "expected %e, got %e\n", mpfr_get_d (ref),
- mpfr_get_d (res));
+ mpfr_get_d1 (op1), mpfr_get_d1 (op2), mpfr_get_d1 (op3));
+ fprintf (stderr, "expected %e, got %e\n", mpfr_get_d1 (ref),
+ mpfr_get_d1 (res));
exit (1);
}
@@ -246,9 +248,9 @@ test4 (char *foo, mp_prec_t prec, mp_rnd_t rnd)
fprintf (stderr,
"Error for %s(a, a, b, a) for a=%e, a=%e, c=%e\n",
foo,
- mpfr_get_d (op1), mpfr_get_d (op2), mpfr_get_d (op3));
- fprintf (stderr, "expected %e, got %e\n", mpfr_get_d (ref),
- mpfr_get_d (res));
+ mpfr_get_d1 (op1), mpfr_get_d1 (op2), mpfr_get_d1 (op3));
+ fprintf (stderr, "expected %e, got %e\n", mpfr_get_d1 (ref),
+ mpfr_get_d1 (res));
exit (1);
}
@@ -261,9 +263,9 @@ test4 (char *foo, mp_prec_t prec, mp_rnd_t rnd)
fprintf (stderr,
"Error for %s(b, a, b, b) for a=%e, a=%e, c=%e\n",
foo,
- mpfr_get_d (op1), mpfr_get_d (op2), mpfr_get_d (op3));
- fprintf (stderr, "expected %e, got %e\n", mpfr_get_d (ref),
- mpfr_get_d (res));
+ mpfr_get_d1 (op1), mpfr_get_d1 (op2), mpfr_get_d1 (op3));
+ fprintf (stderr, "expected %e, got %e\n", mpfr_get_d1 (ref),
+ mpfr_get_d1 (res));
exit (1);
}
@@ -275,9 +277,9 @@ test4 (char *foo, mp_prec_t prec, mp_rnd_t rnd)
{
fprintf (stderr,
"Error for %s(a, a, a, a) for a=%e\n", foo,
- mpfr_get_d (op1));
- fprintf (stderr, "expected %e, got %e\n", mpfr_get_d (ref),
- mpfr_get_d (res));
+ mpfr_get_d1 (op1));
+ fprintf (stderr, "expected %e, got %e\n", mpfr_get_d1 (ref),
+ mpfr_get_d1 (res));
exit (1);
}
}
@@ -314,9 +316,9 @@ test2ui (char *foo, mp_prec_t prec, mp_rnd_t rnd)
ref3 can be 0 or any number */
for (i=0; i<12; i++)
{
- if (i%6==0) MPFR_SET_NAN(ref2);
- if (i%6==1) mpfr_set_d (ref2, 1.0/0.0, GMP_RNDN);
- if (i%6==2) mpfr_set_d (ref2, -1.0/0.0, GMP_RNDN);
+ if (i%6==0) mpfr_set_nan (ref2);
+ if (i%6==1) mpfr_set_inf (ref2, 1);
+ if (i%6==2) mpfr_set_inf (ref2, -1);
if (i%6==3) mpfr_set_d (ref2, 0.0, GMP_RNDN);
if (i%6==4) mpfr_set_d (ref2, -0.0, GMP_RNDN);
if (i%6==5) mpfr_random (ref2);
@@ -339,9 +341,9 @@ test2ui (char *foo, mp_prec_t prec, mp_rnd_t rnd)
if (mpfr_compare (res1, ref1))
{
fprintf (stderr, "Error for %s(a, a, c) for a=%e c=%u\n", foo,
- mpfr_get_d (ref2), ref3);
- fprintf (stderr, "expected %e, got %e\n", mpfr_get_d (ref1),
- mpfr_get_d (res1));
+ mpfr_get_d1 (ref2), ref3);
+ fprintf (stderr, "expected %e, got %e\n", mpfr_get_d1 (ref1),
+ mpfr_get_d1 (res1));
exit (1);
}
}
@@ -371,9 +373,9 @@ testui2 (char *foo, mp_prec_t prec, mp_rnd_t rnd)
ref2 = (unsigned int) c[0];
for (i=0; i<12; i++) {
- if (i%6==0) MPFR_SET_NAN(ref3);
- if (i%6==1) mpfr_set_d (ref3, 1.0/0.0, GMP_RNDN);
- if (i%6==2) mpfr_set_d (ref3, -1.0/0.0, GMP_RNDN);
+ if (i%6==0) mpfr_set_nan (ref3);
+ if (i%6==1) mpfr_set_inf (ref3, 1);
+ if (i%6==2) mpfr_set_inf (ref3, -1);
if (i%6==3) mpfr_set_d (ref3, 0.0, GMP_RNDN);
if (i%6==4) mpfr_set_d (ref3, -0.0, GMP_RNDN);
if (i%6==5) mpfr_random (ref3);
@@ -392,9 +394,9 @@ testui2 (char *foo, mp_prec_t prec, mp_rnd_t rnd)
testfunc (res1, ref2, res1, rnd);
if (mpfr_compare (res1, ref1)) {
fprintf (stderr, "Error for %s(a, b, a) for b=%u a=%e\n", foo,
- ref2, mpfr_get_d (ref3));
- fprintf (stderr, "expected %e, got %e\n", mpfr_get_d (ref1),
- mpfr_get_d (res1));
+ ref2, mpfr_get_d1 (ref3));
+ fprintf (stderr, "expected %e, got %e\n", mpfr_get_d1 (ref1),
+ mpfr_get_d1 (res1));
exit (1);
}
}
@@ -421,9 +423,9 @@ test2 (char *foo, mp_prec_t prec, mp_rnd_t rnd)
mpfr_random (ref2);
for (i=0; i<6; i++) {
- if (i==0) MPFR_SET_NAN(ref2);
- if (i==1) mpfr_set_d (ref2, 1.0/0.0, GMP_RNDN);
- if (i==2) mpfr_set_d (ref2, -1.0/0.0, GMP_RNDN);
+ if (i==0) mpfr_set_nan (ref2);
+ if (i==1) mpfr_set_inf (ref2, 1);
+ if (i==2) mpfr_set_inf (ref2, -1);
if (i==3) mpfr_set_d (ref2, 0.0, GMP_RNDN);
if (i==4) mpfr_set_d (ref2, -0.0, GMP_RNDN);
if (i==5) mpfr_random (ref2);
@@ -435,9 +437,9 @@ test2 (char *foo, mp_prec_t prec, mp_rnd_t rnd)
mpfr_set (res1, ref2, rnd); /* exact operation */
testfunc (res1, res1, rnd);
if (mpfr_compare (res1, ref1)) {
- fprintf (stderr, "Error for %s(a, a) for a=%e\n", foo, mpfr_get_d (ref2));
- fprintf (stderr, "expected %e, got %e\n", mpfr_get_d (ref1),
- mpfr_get_d (res1));
+ fprintf (stderr, "Error for %s(a, a) for a=%e\n", foo, mpfr_get_d1 (ref2));
+ fprintf (stderr, "expected %e, got %e\n", mpfr_get_d1 (ref1),
+ mpfr_get_d1 (res1));
exit (1);
}
}
@@ -464,9 +466,9 @@ test2a (char *foo, mp_prec_t prec)
mpfr_random (ref2);
for (i=0; i<6; i++) {
- if (i==0) MPFR_SET_NAN(ref2);
- if (i==1) mpfr_set_d (ref2, 1.0/0.0, GMP_RNDN);
- if (i==2) mpfr_set_d (ref2, -1.0/0.0, GMP_RNDN);
+ if (i==0) mpfr_set_nan (ref2);
+ if (i==1) mpfr_set_inf (ref2, 1);
+ if (i==2) mpfr_set_inf (ref2, -1);
if (i==3) mpfr_set_d (ref2, 0.0, GMP_RNDN);
if (i==4) mpfr_set_d (ref2, -0.0, GMP_RNDN);
if (i==5) mpfr_random (ref2);
@@ -478,9 +480,9 @@ test2a (char *foo, mp_prec_t prec)
mpfr_set (res1, ref2, GMP_RNDN); /* exact operation */
testfunc (res1, res1);
if (mpfr_compare (res1, ref1)) {
- fprintf (stderr, "Error for %s(a, a) for a=%e\n", foo, mpfr_get_d (ref2));
- fprintf (stderr, "expected %e, got %e\n", mpfr_get_d (ref1),
- mpfr_get_d (res1));
+ fprintf (stderr, "Error for %s(a, a) for a=%e\n", foo, mpfr_get_d1 (ref2));
+ fprintf (stderr, "expected %e, got %e\n", mpfr_get_d1 (ref1),
+ mpfr_get_d1 (res1));
exit (1);
}
}
@@ -509,9 +511,9 @@ test3a (char *foo, mp_prec_t prec, mp_rnd_t rnd)
mpfr_random (ref3);
for (i=0; i<6; i++) {
- if (i==0) MPFR_SET_NAN(ref3);
- if (i==1) mpfr_set_d (ref3, 1.0/0.0, GMP_RNDN);
- if (i==2) mpfr_set_d (ref3, -1.0/0.0, GMP_RNDN);
+ if (i==0) mpfr_set_nan (ref3);
+ if (i==1) mpfr_set_inf (ref3, 1);
+ if (i==2) mpfr_set_inf (ref3, -1);
if (i==3) mpfr_set_d (ref3, 0.0, GMP_RNDN);
if (i==4) mpfr_set_d (ref3, -0.0, GMP_RNDN);
if (i==5) mpfr_random (ref3);
@@ -523,9 +525,9 @@ test3a (char *foo, mp_prec_t prec, mp_rnd_t rnd)
mpfr_set (res1, ref3, rnd); /* exact operation */
testfunc (res1, res2, res1, rnd);
if (mpfr_compare (res1, ref1) || mpfr_compare (res2, ref2)) {
- fprintf (stderr, "Error for %s(a, b, a) for a=%e\n", foo, mpfr_get_d (ref3));
- fprintf (stderr, "expected (%e,%e), got (%e,%e)\n", mpfr_get_d (ref1),
- mpfr_get_d (ref2), mpfr_get_d (res1), mpfr_get_d (res2));
+ fprintf (stderr, "Error for %s(a, b, a) for a=%e\n", foo, mpfr_get_d1 (ref3));
+ fprintf (stderr, "expected (%e,%e), got (%e,%e)\n", mpfr_get_d1 (ref1),
+ mpfr_get_d1 (ref2), mpfr_get_d1 (res1), mpfr_get_d1 (res2));
exit (1);
}
@@ -533,9 +535,9 @@ test3a (char *foo, mp_prec_t prec, mp_rnd_t rnd)
mpfr_set (res2, ref3, rnd); /* exact operation */
testfunc (res1, res2, res2, rnd);
if (mpfr_compare (res1, ref1) || mpfr_compare (res2, ref2)) {
- fprintf (stderr, "Error for %s(a, b, b) for b=%e\n", foo, mpfr_get_d (ref3));
- fprintf (stderr, "expected (%e,%e), got (%e,%e)\n", mpfr_get_d (ref1),
- mpfr_get_d (ref2), mpfr_get_d (res1), mpfr_get_d (res2));
+ fprintf (stderr, "Error for %s(a, b, b) for b=%e\n", foo, mpfr_get_d1 (ref3));
+ fprintf (stderr, "expected (%e,%e), got (%e,%e)\n", mpfr_get_d1 (ref1),
+ mpfr_get_d1 (ref2), mpfr_get_d1 (res1), mpfr_get_d1 (res2));
exit (1);
}
}
@@ -550,45 +552,44 @@ test3a (char *foo, mp_prec_t prec, mp_rnd_t rnd)
int
main (void)
{
- testfunc = (void*) mpfr_add; test3 ("mpfr_add", 53, GMP_RNDN);
- testfunc = (void*) mpfr_add_ui; test2ui ("mpfr_add_ui", 53, GMP_RNDN);
- testfunc = mpfr_agm; test3 ("mpfr_agm", 53, GMP_RNDN);
- testfunc = (void*) mpfr_ceil; test2 ("mpfr_ceil", 53, GMP_RNDN);
- testfunc = (void*) mpfr_div; test3 ("mpfr_div", 53, GMP_RNDN);
- testfunc = (void*) mpfr_div_2exp; test2ui ("mpfr_div_2exp", 53, GMP_RNDN);
- testfunc = (void*) mpfr_div_ui; test2ui ("mpfr_div_ui", 53, GMP_RNDN);
- testfunc = (void*) mpfr_exp; test2 ("mpfr_exp", 53, GMP_RNDN);
- testfunc = (void*) mpfr_floor; test2 ("mpfr_floor", 53, GMP_RNDN);
- testfunc = (void*) mpfr_log; test2 ("mpfr_log", 53, GMP_RNDN);
- testfunc = (void*) mpfr_mul; test3 ("mpfr_mul", 53, GMP_RNDN);
- testfunc = (void*) mpfr_mul_2exp; test2ui ("mpfr_mul_2exp", 53, GMP_RNDN);
- testfunc = (void*) mpfr_mul_ui; test2ui ("mpfr_mul_ui", 53, GMP_RNDN);
- testfunc = (void*) mpfr_neg; test2 ("mpfr_neg", 53, GMP_RNDN);
- testfunc = (void*) mpfr_pow_ui; test2ui ("mpfr_pow_ui", 53, GMP_RNDN);
- testfunc = mpfr_reldiff; test3 ("mpfr_reldiff", 53, GMP_RNDN);
- testfunc = (void*) mpfr_sub; test3 ("mpfr_sub", 53, GMP_RNDN);
- testfunc = (void*) mpfr_sub_ui; test2ui ("mpfr_sub_ui", 53, GMP_RNDN);
- testfunc = (void*) mpfr_sqrt; test2 ("mpfr_sqrt", 53, GMP_RNDN);
- testfunc = (void*) mpfr_ui_div; testui2 ("mpfr_ui_div", 53, GMP_RNDN);
- testfunc = (void*) mpfr_ui_sub; testui2 ("mpfr_ui_sub", 53, GMP_RNDN);
- testfunc = (void*) mpfr_trunc; test2 ("mpfr_trunc", 53, GMP_RNDN);
- testfunc = (void*) mpfr_asin; test2 ("mpfr_asin", 53, GMP_RNDN);
- testfunc = (void*) mpfr_acos; test2 ("mpfr_acos", 53, GMP_RNDN);
- testfunc = (void*) mpfr_atan; test2 ("mpfr_atan", 53, GMP_RNDN);
- testfunc = (void*) mpfr_sinh; test2 ("mpfr_sinh", 53, GMP_RNDN);
- testfunc = (void*) mpfr_cosh; test2 ("mpfr_cosh", 53, GMP_RNDN);
- testfunc = (void*) mpfr_tanh; test2 ("mpfr_tanh", 53, GMP_RNDN);
- testfunc = (void*) mpfr_asinh; test2 ("mpfr_asinh", 53, GMP_RNDN);
- testfunc = (void*) mpfr_acosh; test2 ("mpfr_acosh", 53, GMP_RNDN);
- testfunc = (void*) mpfr_atanh; test2 ("mpfr_atanh", 53, GMP_RNDN);
- testfunc = (void*) mpfr_exp2; test2 ("mpfr_exp2", 53, GMP_RNDN);
- testfunc = (void*) mpfr_cos; test2 ("mpfr_cos", 53, GMP_RNDN);
- testfunc = (void*) mpfr_sin; test2 ("mpfr_sin", 53, GMP_RNDN);
- testfunc = (void*) mpfr_tan; test2 ("mpfr_tan", 53, GMP_RNDN);
- testfunc = (void*) mpfr_log10; test2 ("mpfr_log10", 53, GMP_RNDN);
- testfunc = (void*) mpfr_log2; test2 ("mpfr_log2", 53, GMP_RNDN);
- testfunc = (void*) mpfr_pow; test3 ("mpfr_pow", 53, GMP_RNDN);
- testfunc = (void*) mpfr_fma; test4 ("mpfr_fma", 53, GMP_RNDN);
+ testfunc = (fct_t) mpfr_add; test3 ("mpfr_add", 53, GMP_RNDN);
+ testfunc = (fct_t) mpfr_add_ui; test2ui ("mpfr_add_ui", 53, GMP_RNDN);
+ testfunc = (fct_t) mpfr_agm; test3 ("mpfr_agm", 53, GMP_RNDN);
+ testfunc = (fct_t) mpfr_ceil; test2 ("mpfr_ceil", 53, GMP_RNDN);
+ testfunc = (fct_t) mpfr_div; test3 ("mpfr_div", 53, GMP_RNDN);
+ testfunc = (fct_t) mpfr_div_2exp; test2ui ("mpfr_div_2exp", 53, GMP_RNDN);
+ testfunc = (fct_t) mpfr_div_ui; test2ui ("mpfr_div_ui", 53, GMP_RNDN);
+ testfunc = (fct_t) mpfr_exp; test2 ("mpfr_exp", 53, GMP_RNDN);
+ testfunc = (fct_t) mpfr_floor; test2 ("mpfr_floor", 53, GMP_RNDN);
+ testfunc = (fct_t) mpfr_log; test2 ("mpfr_log", 53, GMP_RNDN);
+ testfunc = (fct_t) mpfr_mul; test3 ("mpfr_mul", 53, GMP_RNDN);
+ testfunc = (fct_t) mpfr_mul_2exp; test2ui ("mpfr_mul_2exp", 53, GMP_RNDN);
+ testfunc = (fct_t) mpfr_mul_ui; test2ui ("mpfr_mul_ui", 53, GMP_RNDN);
+ testfunc = (fct_t) mpfr_neg; test2 ("mpfr_neg", 53, GMP_RNDN);
+ testfunc = (fct_t) mpfr_pow_ui; test2ui ("mpfr_pow_ui", 53, GMP_RNDN);
+ testfunc = (fct_t) mpfr_reldiff; test3 ("mpfr_reldiff", 53, GMP_RNDN);
+ testfunc = (fct_t) mpfr_sub; test3 ("mpfr_sub", 53, GMP_RNDN);
+ testfunc = (fct_t) mpfr_sub_ui; test2ui ("mpfr_sub_ui", 53, GMP_RNDN);
+ testfunc = (fct_t) mpfr_sqrt; test2 ("mpfr_sqrt", 53, GMP_RNDN);
+ testfunc = (fct_t) mpfr_ui_div; testui2 ("mpfr_ui_div", 53, GMP_RNDN);
+ testfunc = (fct_t) mpfr_ui_sub; testui2 ("mpfr_ui_sub", 53, GMP_RNDN);
+ testfunc = (fct_t) mpfr_trunc; test2 ("mpfr_trunc", 53, GMP_RNDN);
+ testfunc = (fct_t) mpfr_asin; test2 ("mpfr_asin", 53, GMP_RNDN);
+ testfunc = (fct_t) mpfr_acos; test2 ("mpfr_acos", 53, GMP_RNDN);
+ testfunc = (fct_t) mpfr_atan; test2 ("mpfr_atan", 53, GMP_RNDN);
+ testfunc = (fct_t) mpfr_sinh; test2 ("mpfr_sinh", 53, GMP_RNDN);
+ testfunc = (fct_t) mpfr_cosh; test2 ("mpfr_cosh", 53, GMP_RNDN);
+ testfunc = (fct_t) mpfr_tanh; test2 ("mpfr_tanh", 53, GMP_RNDN);
+ testfunc = (fct_t) mpfr_asinh; test2 ("mpfr_asinh", 53, GMP_RNDN);
+ testfunc = (fct_t) mpfr_acosh; test2 ("mpfr_acosh", 53, GMP_RNDN);
+ testfunc = (fct_t) mpfr_atanh; test2 ("mpfr_atanh", 53, GMP_RNDN);
+ testfunc = (fct_t) mpfr_exp2; test2 ("mpfr_exp2", 53, GMP_RNDN);
+ testfunc = (fct_t) mpfr_cos; test2 ("mpfr_cos", 53, GMP_RNDN);
+ testfunc = (fct_t) mpfr_sin; test2 ("mpfr_sin", 53, GMP_RNDN);
+ testfunc = (fct_t) mpfr_tan; test2 ("mpfr_tan", 53, GMP_RNDN);
+ testfunc = (fct_t) mpfr_log10; test2 ("mpfr_log10", 53, GMP_RNDN);
+ testfunc = (fct_t) mpfr_log2; test2 ("mpfr_log2", 53, GMP_RNDN);
+ testfunc = (fct_t) mpfr_pow; test3 ("mpfr_pow", 53, GMP_RNDN);
+ testfunc = (fct_t) mpfr_fma; test4 ("mpfr_fma", 53, GMP_RNDN);
return 0;
}
-
diff --git a/mpfr/tests/tabs.c b/mpfr/tests/tabs.c
index 193a51f6c..308fca23b 100644
--- a/mpfr/tests/tabs.c
+++ b/mpfr/tests/tabs.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_abs.
-Copyright (C) 2000-2002 Free Software Foundation, Inc.
+Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -23,10 +23,9 @@ MA 02111-1307, USA. */
#include <stdlib.h>
#include "gmp.h"
#include "mpfr.h"
+#include "mpfr-impl.h"
#include "mpfr-test.h"
-#define Infp (1/0.)
-
void check_inexact _PROTO((void));
void
@@ -46,7 +45,7 @@ check_inexact (void)
mpfr_set_prec (x, p);
mpfr_set_prec (absx, p);
mpfr_random (x);
- if (rand () % 2)
+ if (LONG_RAND () % 2)
{
mpfr_set (absx, x, GMP_RNDN);
mpfr_neg (x, x, GMP_RNDN);
@@ -82,14 +81,11 @@ check_inexact (void)
int
main (int argc, char *argv[])
{
- mpfr_t x; int n, k, rnd; double d, dd;
-#ifdef __mips
- /* to get denormalized numbers on IRIX64 */
- union fpc_csr exp;
- exp.fc_word = get_fpc_csr();
- exp.fc_struct.flush = 0;
- set_fpc_csr(exp.fc_word);
-#endif
+ mpfr_t x;
+ int n, k, rnd;
+ double d, absd, dd;
+
+ mpfr_test_init ();
check_inexact ();
@@ -97,41 +93,54 @@ main (int argc, char *argv[])
mpfr_set_d(x, 1.0, GMP_RNDN);
mpfr_abs(x, x, GMP_RNDN);
- if (mpfr_get_d(x) != 1.0) {
+ if (mpfr_get_d1 (x) != 1.0) {
fprintf(stderr, "Error in mpfr_abs(1.0)\n"); exit(1);
}
mpfr_set_d(x, -1.0, GMP_RNDN);
mpfr_abs(x, x, GMP_RNDN);
- if (mpfr_get_d(x) != 1.0) {
+ if (mpfr_get_d1 (x) != 1.0) {
fprintf(stderr, "Error in mpfr_abs(-1.0)\n"); exit(1);
}
- mpfr_set_d(x, -6/-0., GMP_RNDN);
- mpfr_abs(x, x, GMP_RNDN);
- if (mpfr_get_d(x) != Infp) {
- fprintf(stderr, "Error in mpfr_abs(Inf).\n"); exit(1);
- }
-
- mpfr_set_d(x, 2/-0., GMP_RNDN);
- mpfr_abs(x, x, GMP_RNDN);
- if (mpfr_get_d(x) != Infp) {
- fprintf(stderr, "Error in mpfr_abs(-Inf).\n"); exit(1);
- }
+ mpfr_set_inf (x, 1);
+ mpfr_abs (x, x, GMP_RNDN);
+ if (!mpfr_inf_p(x) || (mpfr_sgn(x) <= 0))
+ {
+ fprintf (stderr, "Error in mpfr_abs(Inf).\n");
+ exit (1);
+ }
+ mpfr_set_inf (x, -1);
+ mpfr_abs (x, x, GMP_RNDN);
+ if (!mpfr_inf_p(x) || (mpfr_sgn(x) <= 0))
+ {
+ fprintf (stderr, "Error in mpfr_abs(-Inf).\n");
+ exit (1);
+ }
n = (argc==1) ? 1000000 : atoi(argv[1]);
for (k = 1; k <= n; k++)
- {
- d = drand();
- rnd = rand() % 4;
- mpfr_set_d(x, d, 0);
- mpfr_abs(x, x, rnd);
- dd = mpfr_get_d(x);
- if (!isnan(d) && dd != ABS(d))
+ {
+ do
+ {
+ d = drand ();
+ absd = ABS(d);
+ }
+#ifdef HAVE_DENORMS
+ while (0);
+#else
+ while (absd <= 2.2e-307);
+#endif
+ rnd = LONG_RAND() % 4;
+ mpfr_set_d (x, d, 0);
+ mpfr_abs (x, x, rnd);
+ dd = mpfr_get_d1 (x);
+ if (!isnan(d) && (dd != absd))
{
fprintf(stderr,
- "Mismatch on d = %1.18g\n", d);
+ "Mismatch on d = %.20e\n", d);
+ fprintf(stderr, "dd=%.20e\n", dd);
mpfr_print_binary(x); putchar('\n');
exit(1);
}
diff --git a/mpfr/tests/tacos.c b/mpfr/tests/tacos.c
index dd07b1b00..50e9ee666 100644
--- a/mpfr/tests/tacos.c
+++ b/mpfr/tests/tacos.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_acos.
-Copyright (C) 2001 Free Software Foundation.
+Copyright 2001 Free Software Foundation.
Contributed by Mathieu Dutour.
This file is part of the MPFR Library.
@@ -16,7 +16,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/tests/tacosh.c b/mpfr/tests/tacosh.c
index e3fcedea6..624661582 100644
--- a/mpfr/tests/tacosh.c
+++ b/mpfr/tests/tacosh.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_acosh.
-Copyright (C) 2001 Free Software Foundation.
+Copyright 2001 Free Software Foundation.
Adapted from tarctan.c.
This file is part of the MPFR Library.
@@ -16,7 +16,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/tests/tadd.c b/mpfr/tests/tadd.c
index e540a9fbb..546483127 100644
--- a/mpfr/tests/tadd.c
+++ b/mpfr/tests/tadd.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_add and mpfr_sub.
-Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation.
+Copyright 1999, 2000, 2001, 2002 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -23,12 +23,12 @@ MA 02111-1307, USA. */
#include <stdio.h>
#include <stdlib.h>
+#include <time.h>
#include "gmp.h"
#include "mpfr.h"
#include "mpfr-impl.h"
#include "mpfr-test.h"
-extern int getpid();
void check _PROTO((double, double, mp_rnd_t, unsigned int, unsigned int, unsigned int, double));
void checknan _PROTO((double, double, mp_rnd_t, unsigned int, unsigned int, unsigned int));
void check3 _PROTO((double, double, mp_rnd_t));
@@ -56,12 +56,12 @@ check (double x, double y, mp_rnd_t rnd_mode, unsigned int px,
mpfr_set_d(xx, x, rnd_mode);
mpfr_set_d(yy, y, rnd_mode);
mpfr_add(zz, xx, yy, rnd_mode);
-#ifdef TEST
+#ifdef HAVE_FENV_H
mpfr_set_machine_rnd_mode(rnd_mode);
if (px==53 && py==53 && pz==53) cert=1;
#endif
if (z1==0.0) z1=x+y; else cert=1;
- z2 = mpfr_get_d(zz);
+ z2 = mpfr_get_d1 (zz);
mpfr_set_d (yy, z2, GMP_RNDN);
if (!mpfr_cmp (zz, yy) && cert && z1!=z2 && !(isnan(z1) && isnan(z2))) {
printf("expected sum is %1.20e, got %1.20e\n",z1,z2);
@@ -84,24 +84,24 @@ checknan (double x, double y, mp_rnd_t rnd_mode, unsigned int px,
mpfr_set_d(xx, x, rnd_mode);
mpfr_set_d(yy, y, rnd_mode);
mpfr_add(zz, xx, yy, rnd_mode);
-#ifdef TEST
+#ifdef HAVE_FENV_H
mpfr_set_machine_rnd_mode(rnd_mode);
#endif
if (MPFR_IS_NAN(zz) == 0) { printf("Error, not an MPFR_NAN for xx = %1.20e, y = %1.20e\n", x, y); exit(1); }
- z2 = mpfr_get_d(zz);
- if (!isnan(z2)) { printf("Error, not a NaN after conversion, xx = %1.20e yy = %1.20e\n", x, y); exit(1); }
+ z2 = mpfr_get_d1 (zz);
+ if (!isnan(z2)) { printf("Error, not a NaN after conversion, xx = %1.20e yy = %1.20e, got %1.20e\n", x, y, z2); exit(1); }
mpfr_clear(xx); mpfr_clear(yy); mpfr_clear(zz);
}
-#ifdef TEST
+#ifdef HAVE_FENV_H
/* idem than check for mpfr_add(x, x, y) */
void
check3 (double x, double y, mp_rnd_t rnd_mode)
{
double z1,z2; mpfr_t xx,yy; int neg;
- neg = rand() % 2;
+ neg = LONG_RAND() % 2;
mpfr_init2(xx, 53);
mpfr_init2(yy, 53);
mpfr_set_d(xx, x, rnd_mode);
@@ -110,7 +110,7 @@ check3 (double x, double y, mp_rnd_t rnd_mode)
else mpfr_add(xx, xx, yy, rnd_mode);
mpfr_set_machine_rnd_mode(rnd_mode);
z1 = (neg) ? x-y : x+y;
- z2 = mpfr_get_d(xx);
+ z2 = mpfr_get_d1 (xx);
mpfr_set_d (yy, z2, GMP_RNDN);
if (!mpfr_cmp (xx, yy) && z1!=z2 && !(isnan(z1) && isnan(z2))) {
printf("expected result is %1.20e, got %1.20e\n",z1,z2);
@@ -129,7 +129,7 @@ check4 (double x, double y, mp_rnd_t rnd_mode)
mpfr_t xx, yy;
int neg;
- neg = rand() % 2;
+ neg = LONG_RAND() % 2;
mpfr_init2(xx, 53);
mpfr_init2(yy, 53);
mpfr_set_d(xx, x, rnd_mode);
@@ -138,7 +138,7 @@ check4 (double x, double y, mp_rnd_t rnd_mode)
else mpfr_add(xx, yy, xx, rnd_mode);
mpfr_set_machine_rnd_mode(rnd_mode);
z1 = (neg) ? y-x : x+y;
- z2 = mpfr_get_d(xx);
+ z2 = mpfr_get_d1 (xx);
mpfr_set_d (yy, z2, GMP_RNDN);
/* check that xx is representable as a double and no overflow occurred */
if ((mpfr_cmp (xx, yy) == 0) && (z1 != z2)) {
@@ -158,13 +158,13 @@ check5 (double x, mp_rnd_t rnd_mode)
mpfr_init2(xx, 53);
mpfr_init2(yy, 53);
- neg = rand() % 2;
+ neg = LONG_RAND() % 2;
mpfr_set_d(xx, x, rnd_mode);
if (neg) mpfr_sub(xx, xx, xx, rnd_mode);
else mpfr_add(xx, xx, xx, rnd_mode);
mpfr_set_machine_rnd_mode(rnd_mode);
z1 = (neg) ? x-x : x+x;
- z2 = mpfr_get_d(xx);
+ z2 = mpfr_get_d1 (xx);
mpfr_set_d (yy, z2, GMP_RNDN);
/* check NaNs first since mpfr_cmp does not like them */
if (!(isnan(z1) && isnan(z2)) && !mpfr_cmp (xx, yy) && z1!=z2)
@@ -188,7 +188,7 @@ check2 (double x, int px, double y, int py, int pz, mp_rnd_t rnd_mode)
mpfr_set_d(yy, y, rnd_mode);
mpfr_add(zz, xx, yy, rnd_mode);
mpfr_set_machine_rnd_mode(rnd_mode);
- z = x+y; z2=mpfr_get_d(zz); u=ulp(z,z2);
+ z = x+y; z2=mpfr_get_d1 (zz); u=ulp(z,z2);
/* one ulp difference is possible due to composed rounding */
if (px>=53 && py>=53 && pz>=53 && ABS(u)>1) {
printf("x=%1.20e,%d y=%1.20e,%d pz=%d,rnd=%s\n",
@@ -300,7 +300,7 @@ check64 (void)
mpfr_set_d (x, -5.03525136761487735093e-74, GMP_RNDN);
mpfr_set_d (t, 8.51539046314262304109e-91, GMP_RNDN);
mpfr_add (u, x, t, GMP_RNDN);
- if (mpfr_get_d (u) != -5.0352513676148773509283672e-74) {
+ if (mpfr_get_d1 (u) != -5.0352513676148773509283672e-74) {
fprintf (stderr, "mpfr_add(u, x, t) failed for prec(x)=92, prec(t)=86\n");
exit (1);
}
@@ -356,7 +356,7 @@ check64 (void)
mpfr_set_str_raw(x, "0.10011010101000110101010000000011001001001110001011101011111011101E623");
mpfr_set_str_raw(t, "0.10011010101000110101010000000011001001001110001011101011111011100E623");
mpfr_sub(u, x, t, GMP_RNDU);
- if (mpfr_get_d(u) != 9.4349060620538533806e167) { /* 2^558 */
+ if (mpfr_get_d1 (u) != 9.4349060620538533806e167) { /* 2^558 */
printf("Error (1) in mpfr_sub\n"); exit(1);
}
@@ -435,10 +435,10 @@ check64 (void)
/* checks that NaN flag is correctly reset */
mpfr_set_d (t, 1.0, GMP_RNDN);
mpfr_set_d (u, 1.0, GMP_RNDN);
- MPFR_SET_NAN(x);
+ mpfr_set_nan (x);
mpfr_add (x, t, u, GMP_RNDN);
if (mpfr_cmp_ui (x, 2)) {
- fprintf (stderr, "Error in mpfr_add: 1+1 gives %e\n", mpfr_get_d (x));
+ fprintf (stderr, "Error in mpfr_add: 1+1 gives %e\n", mpfr_get_d1 (x));
exit (1);
}
@@ -537,7 +537,7 @@ check_same (void)
mpfr_init(x); mpfr_set_d(x, 1.0, GMP_RNDZ);
mpfr_add(x, x, x, GMP_RNDZ);
- if (mpfr_get_d(x) != 2.0) {
+ if (mpfr_get_d1 (x) != 2.0) {
printf("Error when all 3 operands are equal\n"); exit(1);
}
mpfr_clear(x);
@@ -600,7 +600,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 = rand () % 4;
+ rnd = LONG_RAND () % 4;
if (mpfr_add (z, x, u, rnd))
{
fprintf (stderr, "z <- x + u should be exact\n");
@@ -640,19 +640,15 @@ check_inexact (void)
int
main (int argc, char *argv[])
{
+#ifdef HAVE_FENV_H
int prec, rnd_mode;
-#ifdef TEST
- int i, rnd;
- double x, y;
-#endif
-#ifdef __mips
- /* to get denormalized numbers on IRIX64 */
- union fpc_csr exp;
- exp.fc_word = get_fpc_csr();
- exp.fc_struct.flush = 0;
- set_fpc_csr(exp.fc_word);
+ int rnd;
+ double y;
#endif
+ double x;
+ int i;
+ mpfr_test_init ();
check_inexact ();
check_case_1b ();
check_case_2 ();
@@ -704,7 +700,8 @@ main (int argc, char *argv[])
9.0969267746123943065e196);
check53(3.14553393112021279444e-67, 3.14553401015952024126e-67, GMP_RNDU,
6.2910679412797336946e-67);
- srand(getpid());
+
+ SEED_RAND (time(NULL));
check53(5.43885304644369509058e+185,-1.87427265794105342763e-57,GMP_RNDN,
5.4388530464436950905e185);
check53(5.43885304644369509058e+185,-1.87427265794105342763e-57, GMP_RNDZ,
@@ -737,8 +734,9 @@ main (int argc, char *argv[])
GMP_RNDD, "-b.eae2643497ff6286b@-108");
check2a(-3.31624349995221499866e-22,107,-8.20150212714204839621e+156,79,99,
GMP_RNDD, "-2.63b22b55697e8000000000008@130");
- check2a(-1.08007920352320089721e+150,63,1.77607317509426332389e+73,64,64,
- GMP_RNDN, "-5.4781549356e1c@124");
+ x = -5943982715394951.0; for (i=0; i<446; i++) x *= 2.0;
+ check2a(x, 63, 1.77607317509426332389e+73, 64, 64, GMP_RNDN,
+ "-5.4781549356e1c@124");
check2a(4.49465557237618783128e+53,108,-2.45103927353799477871e+48,60,105,
GMP_RNDN, "4.b14f230f909dc803e@44");
check2a(2.26531902208967707071e+168,99,-2.67795218510613988524e+168,67,94,
@@ -772,8 +770,6 @@ main (int argc, char *argv[])
check2a(2.72046257722708717791e+243,97,-1.62158447436486437113e+243,83,96,
GMP_RNDN, "a.4cc63e002d2e8@201");
/* Checking double precision (53 bits) */
- prec = (argc<2) ? 53 : atoi(argv[1]);
- rnd_mode = (argc<3) ? -1 : atoi(argv[2]);
check53(-8.22183238641455905806e-19, 7.42227178769761587878e-19, GMP_RNDD,
-7.9956059871694317927e-20);
check53(5.82106394662028628236e+234, -5.21514064202368477230e+89, GMP_RNDD,
@@ -786,18 +782,17 @@ main (int argc, char *argv[])
-2.96695924471135255027e27);
check53(1.74693641655743793422e-227, -7.71776956366861843469e-229, GMP_RNDN,
1.669758720920751867e-227);
+ x = -7883040437021647.0; for (i=0; i<468; i++) x = x / 2.0;
check53(-1.03432206392780011159e-125, 1.30127034799251347548e-133, GMP_RNDN,
- -1.0343220509150965661e-125);
+ x);
check53(1.05824655795525779205e+71, -1.06022698059744327881e+71, GMP_RNDZ,
-1.9804226421854867632e68);
check53(-5.84204911040921732219e+240, 7.26658169050749590763e+240, GMP_RNDD,
1.4245325800982785854e240);
- /* the following check double overflow */
- check53(6.27557402141211962228e+307, 1.32141396570101687757e+308,
- GMP_RNDZ, 1.0/0.0);
check53(1.00944884131046636376e+221, 2.33809162651471520268e+215, GMP_RNDN,
1.0094511794020929787e221);
- check53(4.29232078932667367325e-278, 1.07735250473897938332e-281, GMP_RNDU,
+ x = 7045852550057985.0; for (i=0; i<986; i++) x = x / 2.0;
+ check53(4.29232078932667367325e-278, x, GMP_RNDU,
4.2933981418314132787e-278);
check53(5.27584773801377058681e-80, 8.91207657803547196421e-91, GMP_RNDN,
5.2758477381028917269e-80);
@@ -819,14 +814,19 @@ main (int argc, char *argv[])
/* test denormalized numbers too */
check53(8.06294740693074521573e-310, 6.95250701071929654575e-310, GMP_RNDU,
1.5015454417650041761e-309);
- check53(1/0., 6.95250701071929654575e-310, GMP_RNDU, 1/0.);
- check53(-1/0., 6.95250701071929654575e-310, GMP_RNDU, -1/0.);
- check53(6.95250701071929654575e-310, 1/0., GMP_RNDU, 1/0.);
- check53(6.95250701071929654575e-310, -1/0., GMP_RNDU, -1/0.);
+#ifdef HAVE_INFS
+ /* the following check double overflow */
+ check53(6.27557402141211962228e+307, 1.32141396570101687757e+308,
+ GMP_RNDZ, DBL_POS_INF);
+ check53(DBL_POS_INF, 6.95250701071929654575e-310, GMP_RNDU, DBL_POS_INF);
+ check53(DBL_NEG_INF, 6.95250701071929654575e-310, GMP_RNDU, DBL_NEG_INF);
+ check53(6.95250701071929654575e-310, DBL_POS_INF, GMP_RNDU, DBL_POS_INF);
+ check53(6.95250701071929654575e-310, DBL_NEG_INF, GMP_RNDU, DBL_NEG_INF);
+ check53nan (DBL_POS_INF, DBL_NEG_INF, GMP_RNDN);
+#endif
check53(1.44791789689198883921e-140, -1.90982880222349071284e-121,
GMP_RNDN, -1.90982880222349071e-121);
- check53nan(1/0., -1/0., GMP_RNDN);
/* tests for particular cases (Vincent Lefevre, 22 Aug 2001) */
check53(9007199254740992.0, 1.0, GMP_RNDN, 9007199254740992.0);
@@ -835,27 +835,29 @@ main (int argc, char *argv[])
check53(9007199254740994.0, -1.0, GMP_RNDN, 9007199254740992.0);
check53(9007199254740996.0, -1.0, GMP_RNDN, 9007199254740996.0);
-#ifdef TEST
+#ifdef HAVE_FENV_H
+ prec = (argc<2) ? 53 : atoi(argv[1]);
+ rnd_mode = (argc<3) ? -1 : atoi(argv[2]);
/* Comparing to double precision using machine arithmetic */
for (i=0;i<N;i++) {
x = drand();
y = drand();
if (ABS(x)>2.2e-307 && ABS(y)>2.2e-307 && x+y<1.7e+308 && x+y>-1.7e308) {
/* avoid denormalized numbers and overflows */
- rnd = (rnd_mode==-1) ? lrand48()%4 : rnd_mode;
+ rnd = (rnd_mode==-1) ? LONG_RAND()%4 : rnd_mode;
check(x, y, rnd, prec, prec, prec, 0.0);
}
}
/* tests with random precisions */
for (i=0;i<N;i++) {
int px, py, pz;
- px = 53 + (rand() % 64);
- py = 53 + (rand() % 64);
- pz = 53 + (rand() % 64);
- rnd_mode = rand() % 4;
+ px = 53 + (LONG_RAND() % 64);
+ py = 53 + (LONG_RAND() % 64);
+ pz = 53 + (LONG_RAND() % 64);
+ rnd_mode = LONG_RAND() % 4;
do { x = drand(); } while (isnan(x));
do { y = drand(); } while (isnan(y));
- check2(x,px,y,py,pz,rnd_mode);
+ check2 (x, px, y, py, pz, rnd_mode);
}
/* Checking mpfr_add(x, x, y) with prec=53 */
for (i=0;i<N;i++) {
@@ -863,7 +865,7 @@ main (int argc, char *argv[])
y = drand();
if (ABS(x)>2.2e-307 && ABS(y)>2.2e-307 && x+y<1.7e+308 && x+y>-1.7e308) {
/* avoid denormalized numbers and overflows */
- rnd = (rnd_mode==-1) ? lrand48()%4 : rnd_mode;
+ rnd = (rnd_mode==-1) ? LONG_RAND()%4 : rnd_mode;
check3(x, y, rnd);
}
}
@@ -873,7 +875,7 @@ main (int argc, char *argv[])
y = drand();
if (ABS(x)>2.2e-307 && ABS(y)>2.2e-307 && x+y<1.7e+308 && x+y>-1.7e308) {
/* avoid denormalized numbers and overflows */
- rnd = (rnd_mode==-1) ? lrand48()%4 : rnd_mode;
+ rnd = (rnd_mode==-1) ? LONG_RAND()%4 : rnd_mode;
check4(x, y, rnd);
}
}
@@ -881,7 +883,7 @@ main (int argc, char *argv[])
for (i=0;i<N;i++) {
do { x = drand(); } while ((ABS(x)<2.2e-307) || (ABS(x)>0.8e308));
/* avoid denormalized numbers and overflows */
- rnd = (rnd_mode==-1) ? lrand48()%4 : rnd_mode;
+ rnd = (rnd_mode==-1) ? LONG_RAND()%4 : rnd_mode;
check5(x, rnd);
}
#endif
diff --git a/mpfr/tests/tadd_ui.c b/mpfr/tests/tadd_ui.c
index f791c7b76..2321d2586 100644
--- a/mpfr/tests/tadd_ui.c
+++ b/mpfr/tests/tadd_ui.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_add_ui
-Copyright (C) 2000, 2001, 2002 Free Software Foundation.
+Copyright 2000, 2001, 2002 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -25,18 +25,15 @@ MA 02111-1307, USA. */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
+#include <time.h>
#include "gmp.h"
#include "mpfr.h"
#include "mpfr-impl.h"
-#ifdef __mips
-#include <sys/fpu.h>
-#endif
+#include "mpfr-test.h"
void check3 _PROTO((double, unsigned long, unsigned int, double));
void special _PROTO((void));
-#define ABS(x) (((x)>0) ? (x) : (-x))
-
#define check(x,y,r) check3(x,y,r,0.0)
/* checks that x+y gives the same results in double
@@ -50,11 +47,11 @@ check3 (double x, unsigned long y, unsigned int rnd_mode, double z1)
mpfr_init2(zz, 53);
mpfr_set_d(xx, x, rnd_mode);
mpfr_add_ui(zz, xx, y, rnd_mode);
-#ifdef TEST
+#ifdef HAVE_FENV_H
mpfr_set_machine_rnd_mode(rnd_mode);
#endif
if (z1==0.0) z1 = x+y;
- z2 = mpfr_get_d(zz);
+ z2 = mpfr_get_d1 (zz);
if (z1!=z2 && !(isnan(z1) && isnan(z2))) {
printf("expected sum is %1.20e, got %1.20e\n",z1,z2);
printf("mpfr_add_ui failed for x=%1.20e y=%lu with rnd_mode=%s\n",
@@ -80,39 +77,38 @@ special (void)
int
main (int argc, char *argv[])
{
-#ifdef TEST
+#ifdef HAVE_FENV_H
double x; unsigned long y, N; int i,rnd_mode,rnd;
-#ifdef __mips
- /* to get denormalized numbers on IRIX64 */
- union fpc_csr exp;
- exp.fc_word = get_fpc_csr();
- exp.fc_struct.flush = 0;
- set_fpc_csr(exp.fc_word);
-#endif
- srand(getpid());
+ mpfr_test_init ();
+
+ SEED_RAND (time(NULL));
N = (argc<2) ? 1000000 : atoi(argv[1]);
rnd_mode = (argc<3) ? -1 : atoi(argv[2]);
for (i=0;i<1000000;i++) {
- x = drand48();
- y = lrand48();
+ x = drand();
+ y = LONG_RAND();
if (ABS(x)>2.2e-307 && x+y<1.7e+308 && x+y>-1.7e308) {
/* avoid denormalized numbers and overflows */
- rnd = (rnd_mode==-1) ? lrand48()%4 : rnd_mode;
+ rnd = (rnd_mode==-1) ? LONG_RAND()%4 : rnd_mode;
check(x, y, rnd);
}
}
#endif
special ();
- check3(-1.716113812768534e-140, 1271212614, GMP_RNDZ, 1.27121261399999976e9);
- check3(1.22191250737771397120e+20, 948002822, GMP_RNDN,
- 122191250738719408128.0);
- check3(-6.72658901114033715233e-165, 2000878121, GMP_RNDZ,
- 2.0008781209999997615e9);
- check3(-2.0769715792901673e-5, 880524, GMP_RNDN, 8.8052399997923023e5);
- check3(1/0., 2394875, GMP_RNDN, 1/0.);
- check3(-1/0., 2394875, GMP_RNDN, -1/0.);
- check3(0./0., 2394875, GMP_RNDN, 0./0.);
+ check3 (-1.716113812768534e-140, 1271212614, GMP_RNDZ,
+ 1.27121261399999976e9);
+ check3 (1.22191250737771397120e+20, 948002822, GMP_RNDN,
+ 122191250738719408128.0);
+ check3 (-6.72658901114033715233e-165, 2000878121, GMP_RNDZ,
+ 2.0008781209999997615e9);
+ check3 (-2.0769715792901673e-5, 880524, GMP_RNDN, 8.8052399997923023e5);
+#ifdef HAVE_INFS
+ check3 (DBL_POS_INF, 2394875, GMP_RNDN, DBL_POS_INF);
+ check3 (DBL_NEG_INF, 2394875, GMP_RNDN, DBL_NEG_INF);
+ check3 (DBL_NAN, 2394875, GMP_RNDN, DBL_NAN);
+#endif
+
return 0;
}
diff --git a/mpfr/tests/tagm.c b/mpfr/tests/tagm.c
index 8e5802bf0..bacb15b4b 100644
--- a/mpfr/tests/tagm.c
+++ b/mpfr/tests/tagm.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_agm.
-Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+Copyright 1999, 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,15 +15,14 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
-#include <sys/types.h>
-#include <unistd.h>
+#include <time.h>
#include "gmp.h"
#include "mpfr.h"
#include "mpfr-test.h"
@@ -35,16 +34,14 @@ void check_large _PROTO((void));
void slave _PROTO((int, int));
double
-drand_agm(void)
+drand_agm (void)
{
double d; long int *i;
i = (long int*) &d;
do {
- i[0] = lrand48();
- i[1] = lrand48();
- /*if (lrand48()%2) d=-d; */ /* generates negative numbers */
- /* useless here */
+ i[0] = LONG_RAND();
+ i[1] = LONG_RAND();
} while ((d<1e-153)||(d>1e153)); /* to avoid underflow or overflow
in double calculus in sqrt(u*v) */
@@ -92,13 +89,13 @@ check4 (double a, double b, mp_rnd_t rnd_mode, double res1)
mpfr_set_d(tb, b, rnd_mode);
mpfr_agm(tres, ta, tb, rnd_mode);
-#ifdef TEST
+#ifdef HAVE_FENV_H
mpfr_set_machine_rnd_mode(rnd_mode);
#endif
if (res1==0.0) res1=dagm(a,b); else ck=1;
if (ck==0) printf("%1.20e\n", res1);
- res2 = mpfr_get_d(tres);
+ res2 = mpfr_get_d1 (tres);
if (ck && res1!=res2 && (!isnan(res1) || !isnan(res2))) {
printf("mpfr_agm failed for a=%1.20e, b=%1.20e, rnd_mode=%d\n",a,b,rnd_mode);
@@ -132,16 +129,15 @@ slave (int N, int p)
double a,b;
mpfr_t ta, tb, tres;
- srand48(getpid());
mpfr_init2(ta, 53);
mpfr_init2(tb, 53);
mpfr_init2(tres, p);
for(i=0;i<N;i++) {
- a=drand_agm();
- b=drand_agm();
+ a = drand_agm();
+ b = drand_agm();
mpfr_set_d(ta, a, GMP_RNDN);
mpfr_set_d(tb, b, GMP_RNDN);
- mpfr_agm(tres, ta, tb, rand() % 4 );
+ mpfr_agm(tres, ta, tb, LONG_RAND() % 4 );
}
mpfr_clear(ta); mpfr_clear(ta); mpfr_clear(tres);
printf("fin\n");
@@ -153,6 +149,8 @@ main (int argc, char* argv[])
{
int N;
+ SEED_RAND (time(NULL));
+
if (argc==3) { /* tagm N p : N calculus with precision p*/
printf("Doing %d random tests in %d precision\n",atoi(argv[1]),atoi(argv[2]));
slave(atoi(argv[1]),atoi(argv[2]));
@@ -163,12 +161,11 @@ main (int argc, char* argv[])
int i;
double a,b;
- srand48(getpid());
N = atoi(argv[1]);
for (i=0;i<N;i++) {
a = drand();
b = drand();
- check(a, b, rand() % 4);
+ check(a, b, LONG_RAND() % 4);
}
return 0;
}
diff --git a/mpfr/tests/tasin.c b/mpfr/tests/tasin.c
index 018160ce5..469627653 100644
--- a/mpfr/tests/tasin.c
+++ b/mpfr/tests/tasin.c
@@ -1,7 +1,7 @@
/* Test file for mpfr_asin.
-Copyright (C) 2001 Free Software Foundation.
-Contributed by Mathieu Dutour.
+Copyright 2001, 2002 Free Software Foundation.
+Original version by Mathieu Dutour.
This file is part of the MPFR Library.
@@ -16,7 +16,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -37,6 +37,19 @@ main (void)
mpfr_init (y);
mpfr_init (z);
+ /* check that sin(-1) = -Pi/2 */
+ mpfr_set_si (x, -1, GMP_RNDN);
+ mpfr_asin (y, x, GMP_RNDN);
+ mpfr_const_pi (z, GMP_RNDN);
+ mpfr_div_2exp (z, z, 1, GMP_RNDN);
+ mpfr_neg (z, z, GMP_RNDN);
+ if (mpfr_cmp (y, z))
+ {
+ fprintf (stderr, "sin(-1) is wrong, expected %.20e, got %.20e\n",
+ mpfr_get_d1 (z), mpfr_get_d1 (y));
+ exit (1);
+ }
+
for (prec = 2; prec <= 100; prec++)
{
mpfr_set_prec (x, prec);
diff --git a/mpfr/tests/tasinh.c b/mpfr/tests/tasinh.c
index f41bbd8b9..5ef296a17 100644
--- a/mpfr/tests/tasinh.c
+++ b/mpfr/tests/tasinh.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_asinh.
-Copyright (C) 2001 Free Software Foundation.
+Copyright 2001 Free Software Foundation.
Adapted from tarctan.c.
This file is part of the MPFR Library.
@@ -16,7 +16,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/tests/tatan.c b/mpfr/tests/tatan.c
index 7fb8cc365..5e69e3630 100644
--- a/mpfr/tests/tatan.c
+++ b/mpfr/tests/tatan.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_arctan.
-Copyright (C) 2001, 2002 Free Software Foundation.
+Copyright 2001, 2002 Free Software Foundation.
Written by Paul Zimmermann, INRIA Lorraine.
This file is part of the MPFR Library.
@@ -16,7 +16,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/tests/tatanh.c b/mpfr/tests/tatanh.c
index 91469a11a..b1e5ec0cd 100644
--- a/mpfr/tests/tatanh.c
+++ b/mpfr/tests/tatanh.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_atanh.
-Copyright (C) 2001 Free Software Foundation.
+Copyright 2001 Free Software Foundation.
Adapted from tarctan.c.
This file is part of the MPFR Library.
@@ -16,7 +16,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/tests/tcan_round.c b/mpfr/tests/tcan_round.c
index ffbb9023f..5a6a08163 100644
--- a/mpfr/tests/tcan_round.c
+++ b/mpfr/tests/tcan_round.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_can_round.
-Copyright (C) 1999, 2001 Free Software Foundation, Inc.
+Copyright 1999, 2001 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/tests/tcmp.c b/mpfr/tests/tcmp.c
index df6f23bdd..3d04ce6e3 100644
--- a/mpfr/tests/tcmp.c
+++ b/mpfr/tests/tcmp.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_cmp.
-Copyright (C) 1999, 2001 Free Software Foundation, Inc.
+Copyright 1999, 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -27,9 +27,6 @@ MA 02111-1307, USA. */
#include "mpfr-impl.h"
#include "mpfr-test.h"
-#define Infp 1/0.
-#define Infm -1/0.
-
int
main (void)
{
@@ -103,7 +100,7 @@ main (void)
exit(1);
}
- mpfr_set_d(xx, Infp, GMP_RNDN);
+ mpfr_set_inf (xx, 1);
mpfr_set_d(yy, -23489745.0329, GMP_RNDN);
if (mpfr_cmp(xx, yy) <= 0) {
fprintf(stderr,
@@ -111,39 +108,39 @@ main (void)
exit(1);
}
- mpfr_set_d(xx, Infp, GMP_RNDN);
- mpfr_set_d(yy, Infm, GMP_RNDN);
+ mpfr_set_inf (xx, 1);
+ mpfr_set_inf (yy, -1);
if (mpfr_cmp(xx, yy) <= 0) {
fprintf(stderr,
"Error in mpfr_cmp(Infp, Infm), gives %d\n", mpfr_cmp(xx, yy));
exit(1);
}
- mpfr_set_d(xx, Infm, GMP_RNDN);
- mpfr_set_d(yy, Infp, GMP_RNDN);
+ mpfr_set_inf (xx, -1);
+ mpfr_set_inf (yy, 1);
if (mpfr_cmp(xx, yy) >= 0) {
fprintf(stderr,
"Error in mpfr_cmp(Infm, Infp), gives %d\n", mpfr_cmp(xx, yy));
exit(1);
}
- mpfr_set_d(xx, Infp, GMP_RNDN);
- mpfr_set_d(yy, Infp, GMP_RNDN);
+ mpfr_set_inf (xx, 1);
+ mpfr_set_inf (yy, 1);
if (mpfr_cmp(xx, yy) != 0) {
fprintf(stderr,
"Error in mpfr_cmp(Infp, Infp), gives %d\n", mpfr_cmp(xx, yy));
exit(1);
}
- mpfr_set_d(xx, Infm, GMP_RNDN);
- mpfr_set_d(yy, Infm, GMP_RNDN);
+ mpfr_set_inf (xx, -1);
+ mpfr_set_inf (yy, -1);
if (mpfr_cmp(xx, yy) != 0) {
fprintf(stderr,
"Error in mpfr_cmp(Infm, Infm), gives %d\n", mpfr_cmp(xx, yy));
exit(1);
}
- mpfr_set_d(xx, Infm, GMP_RNDN);
+ mpfr_set_inf (xx, -1);
mpfr_set_d(yy, 2346.09234, GMP_RNDN);
if (mpfr_cmp(xx, yy) >= 0) {
fprintf(stderr,
diff --git a/mpfr/tests/tcmp2.c b/mpfr/tests/tcmp2.c
index 691afa933..3f83040c3 100644
--- a/mpfr/tests/tcmp2.c
+++ b/mpfr/tests/tcmp2.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_cmp2.
-Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation.
+Copyright 1999, 2000, 2001, 2002 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -280,13 +280,8 @@ int
main (void)
{
int i,j; double x=1.0, y, z;
-#ifdef __mips
- /* to get denormalized numbers on IRIX64 */
- union fpc_csr exp;
- exp.fc_word = get_fpc_csr();
- exp.fc_struct.flush = 0;
- set_fpc_csr(exp.fc_word);
-#endif
+
+ mpfr_test_init ();
worst_cases ();
special ();
@@ -302,8 +297,8 @@ main (void)
x /= 2.0;
}
for (j=0; j<100000; j++) {
- x = drand48();
- y = drand48();
+ x = DBL_RAND ();
+ y = DBL_RAND ();
if (x<y) { z=x; x=y; y=z; }
if (y != 0.0 && y != -0.0) tcmp2(x, y, -1);
}
diff --git a/mpfr/tests/tcmp_ui.c b/mpfr/tests/tcmp_ui.c
index 601bc3ab3..ba0c565bd 100644
--- a/mpfr/tests/tcmp_ui.c
+++ b/mpfr/tests/tcmp_ui.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_cmp_ui.
-Copyright (C) 1999, 2001 Free Software Foundation, Inc.
+Copyright 1999, 2001 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -34,41 +34,41 @@ main (void)
mpfr_set_ui(x, 3, GMP_RNDZ);
if (mpfr_cmp_ui(x, i=3)!=0) {
- printf("Error in mpfr_cmp_ui(%1.20f,%lu)\n",mpfr_get_d(x), i);
+ printf("Error in mpfr_cmp_ui(%1.20f,%lu)\n",mpfr_get_d1 (x), i);
mpfr_clear(x);
exit(1);
}
if (mpfr_cmp_ui(x, i=2)<=0) {
- printf("Error in mpfr_cmp_ui(%1.20f,%lu)\n",mpfr_get_d(x), i);
+ printf("Error in mpfr_cmp_ui(%1.20f,%lu)\n",mpfr_get_d1 (x), i);
mpfr_clear(x);
exit(1);
}
if (mpfr_cmp_ui(x, i=4)>=0) {
- printf("Error in mpfr_cmp_ui(%1.20f,%lu)\n",mpfr_get_d(x), i);
+ printf("Error in mpfr_cmp_ui(%1.20f,%lu)\n",mpfr_get_d1 (x), i);
mpfr_clear(x);
exit(1);
}
mpfr_set_ui (x, 0, GMP_RNDZ);
mpfr_neg (x, x, GMP_RNDZ);
if (mpfr_cmp_ui (x, i=0)) {
- printf("Error in mpfr_cmp_ui(%1.20f,%lu)\n",mpfr_get_d(x), i);
+ printf("Error in mpfr_cmp_ui(%1.20f,%lu)\n",mpfr_get_d1 (x), i);
mpfr_clear(x);
exit(1);
}
mpfr_set_si(x, -3, GMP_RNDZ);
if (mpfr_cmp_si(x, s=-3)!=0) {
- printf("Error in mpfr_cmp_si(%1.20f,%ld)\n",mpfr_get_d(x), s);
+ printf("Error in mpfr_cmp_si(%1.20f,%ld)\n",mpfr_get_d1 (x), s);
mpfr_clear(x);
exit(1);
}
if (mpfr_cmp_si(x, s=-4)<=0) {
- printf("Error in mpfr_cmp_si(%1.20f,%ld)\n",mpfr_get_d(x), s);
+ printf("Error in mpfr_cmp_si(%1.20f,%ld)\n",mpfr_get_d1 (x), s);
mpfr_clear(x);
exit(1);
}
if (mpfr_cmp_si(x, s=1)>=0) {
- printf("Error in mpfr_cmp_si(%1.20f,%ld)\n",mpfr_get_d(x), s);
+ printf("Error in mpfr_cmp_si(%1.20f,%ld)\n",mpfr_get_d1 (x), s);
mpfr_clear(x);
exit(1);
}
diff --git a/mpfr/tests/tconst_euler.c b/mpfr/tests/tconst_euler.c
index ab9f74321..1d3589a3d 100644
--- a/mpfr/tests/tconst_euler.c
+++ b/mpfr/tests/tconst_euler.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_const_euler.
-Copyright (C) 2001 Free Software Foundation.
+Copyright 2001 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/tests/tconst_log2.c b/mpfr/tests/tconst_log2.c
index b3b120d61..875ebceb3 100644
--- a/mpfr/tests/tconst_log2.c
+++ b/mpfr/tests/tconst_log2.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_const_log2.
-Copyright (C) 1999, 2001 Free Software Foundation, Inc.
+Copyright 1999, 2001 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -86,10 +86,10 @@ main (int argc, char *argv[])
/* check precision of 2 bits */
mpfr_set_prec (x, 2);
mpfr_const_log2 (x, GMP_RNDN);
- if (mpfr_get_d (x) != 0.75)
+ if (mpfr_get_d1 (x) != 0.75)
{
fprintf (stderr, "mpfr_const_log2 failed for prec=2, rnd=GMP_RNDN\n");
- fprintf (stderr, "expected 0.75, got %f\n", mpfr_get_d (x));
+ fprintf (stderr, "expected 0.75, got %f\n", mpfr_get_d1 (x));
exit (1);
}
@@ -104,7 +104,7 @@ main (int argc, char *argv[])
mpfr_set_prec (x, 53);
mpfr_const_log2 (x, rnd);
- if (mpfr_get_d(x) != 6.9314718055994530941e-1)
+ if (mpfr_get_d1 (x) != 6.9314718055994530941e-1)
{
fprintf (stderr, "mpfr_const_log2 failed for prec=53\n");
exit (1);
diff --git a/mpfr/tests/tconst_pi.c b/mpfr/tests/tconst_pi.c
index 60604d3e8..d3f1d742e 100644
--- a/mpfr/tests/tconst_pi.c
+++ b/mpfr/tests/tconst_pi.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_const_pi.
-Copyright (C) 1999, 2001 Free Software Foundation, Inc.
+Copyright 1999, 2001 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -38,7 +38,7 @@ main (int argc, char *argv[])
if (argc>=2) {
printf("Pi="); mpfr_out_str(stdout, 10, 0, x, rnd); putchar('\n');
}
- else if (mpfr_get_d(x) != 3.141592653589793116) {
+ else if (mpfr_get_d1 (x) != 3.141592653589793116) {
fprintf(stderr, "mpfr_const_pi failed for prec=53\n"); exit(1);
}
mpfr_clear(x);
diff --git a/mpfr/tests/tcos.c b/mpfr/tests/tcos.c
index f50767500..60963a879 100644
--- a/mpfr/tests/tcos.c
+++ b/mpfr/tests/tcos.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_cos.
-Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+Copyright 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -24,6 +24,7 @@ MA 02111-1307, USA. */
#include <math.h>
#include "gmp.h"
#include "mpfr.h"
+#include "mpfr-impl.h"
#include "mpfr-test.h"
void check53 _PROTO ((double, double, mp_rnd_t));
@@ -37,12 +38,12 @@ check53 (double x, double cos_x, mp_rnd_t rnd_mode)
mpfr_init2 (c, 53);
mpfr_set_d (xx, x, rnd_mode); /* should be exact */
mpfr_cos (c, xx, rnd_mode);
- if (mpfr_get_d (c) != cos_x && (!isnan(cos_x) || !isnan(mpfr_get_d(c))))
+ if (mpfr_get_d1 (c) != cos_x && (!isnan(cos_x) || !mpfr_nan_p(c)))
{
fprintf (stderr, "mpfr_cos failed for x=%1.20e, rnd=%s\n", x,
mpfr_print_rnd_mode (rnd_mode));
fprintf (stderr, "mpfr_cos gives cos(x)=%1.20e, expected %1.20e\n",
- mpfr_get_d (c), cos_x);
+ mpfr_get_d1 (c), cos_x);
exit (1);
}
mpfr_clear (xx);
@@ -103,9 +104,11 @@ main (int argc, char *argv[])
exit (1);
}
- check53(0.0/0.0, 0.0/0.0, GMP_RNDN);
- check53(1.0/0.0, 0.0/0.0, GMP_RNDN);
- check53(-1.0/0.0, 0.0/0.0, GMP_RNDN);
+#ifdef HAVE_INFS
+ check53 (DBL_NAN, DBL_NAN, GMP_RNDN);
+ check53 (DBL_POS_INF, DBL_NAN, GMP_RNDN);
+ check53 (DBL_NEG_INF, DBL_NAN, GMP_RNDN);
+#endif
/* worst case from PhD thesis of Vincent Lefe`vre: x=8980155785351021/2^54 */
check53 (4.984987858808754279e-1, 8.783012931285841817e-1, GMP_RNDN);
diff --git a/mpfr/tests/tcosh.c b/mpfr/tests/tcosh.c
index 44421b380..119785893 100644
--- a/mpfr/tests/tcosh.c
+++ b/mpfr/tests/tcosh.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_cosh.
-Copyright (C) 2001 Free Software Foundation.
+Copyright 2001 Free Software Foundation.
Adapted from tarctan.c.
This file is part of the MPFR Library.
@@ -16,7 +16,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/tests/tdiv.c b/mpfr/tests/tdiv.c
index 43ab78140..c07c2a3eb 100644
--- a/mpfr/tests/tdiv.c
+++ b/mpfr/tests/tdiv.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_div.
-Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+Copyright 1999, 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,21 +15,19 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
#include <stdio.h>
#include <stdlib.h>
-#include <unistd.h>
+#include <time.h>
#include "gmp.h"
#include "gmp-impl.h"
#include "mpfr.h"
#include "mpfr-impl.h"
#include "mpfr-test.h"
-#define NaN (0./0.)
-
#define check53(n, d, rnd, res) check4(n, d, rnd, 53, res)
void check4 _PROTO((double, double, mp_rnd_t, int, double));
@@ -38,6 +36,7 @@ void check_float _PROTO((void));
void check_convergence _PROTO((void));
void check_lowr _PROTO((void));
void check_inexact _PROTO((void));
+void check_nan _PROTO((void));
void
check4 (double N, double D, mp_rnd_t rnd_mode, int p, double Q)
@@ -48,11 +47,11 @@ check4 (double N, double D, mp_rnd_t rnd_mode, int p, double Q)
mpfr_set_d(n, N, rnd_mode);
mpfr_set_d(d, D, rnd_mode);
mpfr_div(q, n, d, rnd_mode);
-#ifdef TEST
+#ifdef HAVE_FENV_H
mpfr_set_machine_rnd_mode(rnd_mode);
#endif
if (Q==0.0) Q = N/D;
- Q2 = mpfr_get_d(q);
+ Q2 = mpfr_get_d1 (q);
if (p==53 && Q!=Q2 && (!isnan(Q) || !isnan(Q2))) {
printf("mpfr_div failed for n=%1.20e, d=%1.20e, rnd_mode=%s\n",
N, D, mpfr_print_rnd_mode(rnd_mode));
@@ -72,7 +71,7 @@ check24 (float N, float D, mp_rnd_t rnd_mode, float Q)
mpfr_set_d(n, N, rnd_mode);
mpfr_set_d(d, D, rnd_mode);
mpfr_div(q, n, d, rnd_mode);
- Q2 = mpfr_get_d(q);
+ Q2 = mpfr_get_d1 (q);
if (Q!=Q2) {
printf("mpfr_div failed for n=%1.10e, d=%1.10e, prec=24, rnd_mode=%s\n",
N, D, mpfr_print_rnd_mode(rnd_mode));
@@ -451,20 +450,14 @@ int
main (int argc, char *argv[])
{
mpfr_t x, y, z;
- int N;
-
-#ifdef TEST
- int i; double n, d, e;
-#ifdef __mips
- /* to get denormalized numbers on IRIX64 */
- union fpc_csr exp;
- exp.fc_word = get_fpc_csr();
- exp.fc_struct.flush = 0;
- set_fpc_csr(exp.fc_word);
-#endif
+
+#ifdef HAVE_FENV_H
+ int N, i;
+ double n, d, e;
+
+ mpfr_test_init ();
#endif
- N = (argc>1) ? atoi(argv[1]) : 100000;
check_inexact();
mpfr_init2 (x, 64);
@@ -501,14 +494,16 @@ main (int argc, char *argv[])
check53(1.04636807108079349236e-189, 3.72295730823253012954e-292, GMP_RNDZ,
2.810583051186143125e102);
-#ifdef TEST
- srand48(getpid());
- for (i=0;i<N;i++) {
- do { n = drand(); d = drand(); e = ABS(n)/ABS(d); }
- /* smallest normalized is 2^(-1022), largest is 2^(1023)*(2-2^(-52)) */
- while (e>=MAXNORM || e<MINNORM);
- check4(n, d, rand() % 4, 53, 0.0);
- }
+#ifdef HAVE_FENV_H
+ N = (argc>1) ? atoi(argv[1]) : 100000;
+ SEED_RAND (time(NULL));
+ for (i=0;i<N;i++)
+ {
+ do { n = drand(); d = drand(); e = ABS(n)/ABS(d); }
+ /* smallest normalized is 2^(-1022), largest is 2^(1023)*(2-2^(-52)) */
+ while (e>=MAXNORM || e<MINNORM);
+ check4 (n, d, LONG_RAND() % 4, 53, 0.0);
+ }
#endif
mpfr_clear (x);
diff --git a/mpfr/tests/tdiv_ui.c b/mpfr/tests/tdiv_ui.c
index 77de7e123..addc350ab 100644
--- a/mpfr/tests/tdiv_ui.c
+++ b/mpfr/tests/tdiv_ui.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_div_ui.
-Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation.
+Copyright 1999, 2000, 2001, 2002 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,13 +15,13 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
#include <stdio.h>
#include <stdlib.h>
-#include <unistd.h>
+#include <time.h>
#include "gmp.h"
#include "mpfr.h"
#include "mpfr-test.h"
@@ -37,13 +37,13 @@ check (double d, unsigned long u, mp_rnd_t rnd, double e)
double f;
mpfr_init2(x, 53); mpfr_init2(y, 53);
-#ifdef TEST
+#ifdef HAVE_FENV_H
mpfr_set_machine_rnd_mode(rnd);
#endif
if (e==0.0) e = d / u;
mpfr_set_d(x, d, rnd);
mpfr_div_ui(y, x, u, rnd);
- f = mpfr_get_d(y);
+ f = mpfr_get_d1 (y);
if (f != e && (!isnan(f) || !isnan(e))) {
printf("mpfr_div_ui failed for x=%1.20e, u=%lu, rnd=%s\n", d, u,
mpfr_print_rnd_mode(rnd));
@@ -104,7 +104,7 @@ special (void)
{
mpfr_set_prec (y, yprec);
mpfr_div_ui (y, x, 1, GMP_RNDN);
- if (mpfr_get_d (x) != mpfr_get_d (y))
+ if (mpfr_get_d1 (x) != mpfr_get_d1 (y))
{
fprintf (stderr, "division by 1.0 fails for xprec=%u, yprec=%u\n", xprec, yprec);
printf ("expected "); mpfr_print_binary (x); putchar ('\n');
@@ -135,7 +135,7 @@ check_inexact (void)
{
mpfr_set_prec (x, px);
mpfr_random (x);
- do { u = lrand48 (); } while (u == 0);
+ do { u = LONG_RAND (); } while (u == 0);
for (py=2; py<300; py++)
{
mpfr_set_prec (y, py);
@@ -174,15 +174,20 @@ int
main (int argc, char **argv)
{
mpfr_t x;
-#ifdef TEST
- int i; unsigned long u; double d;
-
- srand(getpid());
- for (i=0;i<1000000;i++) {
- do { u = lrand48(); } while (u==0);
- do { d = drand(); } while (ABS(d/u)<2.2e-307);
- check(d, u, rand() % 4, 0.0);
- }
+#ifdef HAVE_FENV_H
+ int i;
+ unsigned long u;
+ double d;
+
+ mpfr_test_init ();
+
+ SEED_RAND (time(NULL));
+ for (i=0;i<1000000;i++)
+ {
+ do { u = LONG_RAND(); } while (u==0);
+ do { d = drand(); } while (ABS(d/u)<2.2e-307);
+ check (d, u, LONG_RAND() % 4, 0.0);
+ }
#endif
check_inexact ();
@@ -201,7 +206,7 @@ main (int argc, char **argv)
mpfr_set_ui(x, 3, GMP_RNDD);
mpfr_log(x, x, GMP_RNDD);
mpfr_div_ui(x, x, 5, GMP_RNDD);
- if (mpfr_get_d(x) != 0.21972245773362189536) {
+ if (mpfr_get_d1 (x) != 0.21972245773362189536) {
fprintf(stderr, "Error in mpfr_div_ui for x=ln(3), u=5\n"); exit(1);
}
mpfr_clear(x);
diff --git a/mpfr/tests/tdump.c b/mpfr/tests/tdump.c
index 8da7069f9..056ae4621 100644
--- a/mpfr/tests/tdump.c
+++ b/mpfr/tests/tdump.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_dump.
-Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,13 +15,12 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
#include <stdio.h>
#include <stdlib.h>
-#include <unistd.h>
#include "gmp.h"
#include "mpfr.h"
diff --git a/mpfr/tests/teq.c b/mpfr/tests/teq.c
index fbb9a82b9..8e77d0d6c 100644
--- a/mpfr/tests/teq.c
+++ b/mpfr/tests/teq.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_eq.
-Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/tests/texceptions.c b/mpfr/tests/texceptions.c
index ed981ba7a..f56f59148 100644
--- a/mpfr/tests/texceptions.c
+++ b/mpfr/tests/texceptions.c
@@ -1,6 +1,6 @@
/* Test file for exceptions.
-Copyright (C) 2001 Free Software Foundation.
+Copyright 2001 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/tests/texp.c b/mpfr/tests/texp.c
index 21e19fb0c..333ff1904 100644
--- a/mpfr/tests/texp.c
+++ b/mpfr/tests/texp.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_exp.
-Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+Copyright 1999, 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,14 +15,14 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
-#include <unistd.h>
+#include <time.h>
#include "gmp.h"
#include "mpfr.h"
#include "mpfr-test.h"
@@ -46,13 +46,13 @@ check3 (double d, mp_rnd_t rnd, double e)
mpfr_t x, y; double f; int u=0, ck=0;
mpfr_init2(x, 53); mpfr_init2(y, 53);
-#ifdef TEST
+#ifdef HAVE_FENV_H
mpfr_set_machine_rnd_mode(rnd);
#endif
if (e==0.0) e = exp(d); else ck=1; /* really check */
mpfr_set_d(x, d, rnd);
mpfr_exp(y, x, rnd);
- f = mpfr_get_d(y);
+ f = mpfr_get_d1 (y);
if (f != e && (!isnan(f) || !isnan(e))) {
u = ulp(e, f);
if (u<0) {
@@ -103,7 +103,7 @@ check_large (double d, int n, mp_rnd_t rnd)
mpfr_out_str(stdout, 10, 0, y, rnd);
putchar('\n');
printf(" ="); mpfr_print_binary(y); putchar('\n');
- if (n==53) printf(" =%1.20e\n", mpfr_get_d(y));
+ if (n==53) printf(" =%1.20e\n", mpfr_get_d1 (y));
mpfr_clear(x); mpfr_clear(y);
return 0;
@@ -118,7 +118,7 @@ check_worst_case (double X, double expx)
mpfr_init2(x, 53); mpfr_init2(y, 53);
mpfr_set_d(x, X, GMP_RNDN);
mpfr_exp(y, x, GMP_RNDD);
- if (mpfr_get_d(y) != expx) {
+ if (mpfr_get_d1 (y) != expx) {
fprintf(stderr, "exp(x) rounded towards -infinity is wrong\n"); exit(1);
}
mpfr_exp(x, x, GMP_RNDN);
@@ -187,7 +187,7 @@ compare_exp2_exp3 (int n)
mpfr_set_prec (y, prec);
mpfr_set_prec (z, prec);
mpfr_random (x);
- rnd = rand() % 4;
+ rnd = LONG_RAND() % 4;
mpfr_exp_2 (y, x, rnd);
mpfr_exp3 (z, x, rnd);
if (mpfr_cmp (y,z))
@@ -216,9 +216,11 @@ compare_exp2_exp3 (int n)
int
main (int argc, char *argv[])
{
-#ifdef TEST
- int i, N, s=0, e, maxe=0; double d, lo, hi;
+#ifdef HAVE_FENV_H
+ int i, N, s=0, e, maxe=0;
+ double lo, hi;
#endif
+ double d;
test_generic (2, 100, 100);
@@ -228,7 +230,6 @@ main (int argc, char *argv[])
exit(1);
}
- srand(getpid());
compare_exp2_exp3(500);
check_worst_cases();
check3(0.0, GMP_RNDU, 1.0);
@@ -258,8 +259,9 @@ main (int argc, char *argv[])
check3(-2.46355324071459982349e+01, GMP_RNDZ, 1.9995129297760994791e-11);
check3(-2.23509444608605427618e+01, GMP_RNDZ, 1.9638492867489702307e-10);
check3(-2.41175390197331687148e+01, GMP_RNDD, 3.3564940885530624592e-11);
- check3(2.46363885231578088053e+01, GMP_RNDU, 5.0055014282693267822e10);
- check3(1.111263531080090984914932e2, GMP_RNDN, 1.8262572323517295459e48);
+ check3(2.46363885231578088053e+01, GMP_RNDU, 5.0055014282693267822e10);
+ d = 7819821913254249.0 / 70368744177664.0;
+ check3(d, GMP_RNDN, 1.8262572323517295459e48);
check3(-3.56196340354684821250e+02, GMP_RNDN, 2.0225297096141478156e-155);
check3(6.59678273772710895173e+02, GMP_RNDU, 3.1234469273830195529e286);
check3(5.13772529701934331570e+02, GMP_RNDD, 1.3445427121297197752e223);
@@ -270,8 +272,8 @@ main (int argc, char *argv[])
check3(5.30015757134837031117e+02, GMP_RNDD, 1.5237672861171573939e230);
check3(5.16239362447650933063e+02, GMP_RNDZ, 1.5845518406744492105e224);
check3(6.00812634798592370977e-01, GMP_RNDN, 1.823600119339019443);
-#ifdef TEST
- srand48(getpid());
+#ifdef HAVE_FENV_H
+ SEED_RAND (time(NULL));
N = (argc==1) ? 0 : atoi(argv[1]);
lo = (argc>=3) ? atof(argv[2]) : -7.083964185e2;
hi = (argc>=4) ? atof(argv[3]) : 7.097827129e2;
@@ -279,8 +281,8 @@ main (int argc, char *argv[])
/* select d such that exp(d) can be represented as a normalized
machine double-precision number,
i.e. 2^(-1022) <= exp(d) <= 2^(1023)*(2-2^(-52)) */
- d = lo + (hi-lo)*drand48();
- e = check(d, rand() % 4);
+ d = lo + (hi-lo)*DBL_RAND();
+ e = check(d, LONG_RAND() % 4);
s += e;
if (e>maxe) maxe=e;
}
diff --git a/mpfr/tests/texp2.c b/mpfr/tests/texp2.c
index 7b9487c45..a464d9dfe 100644
--- a/mpfr/tests/texp2.c
+++ b/mpfr/tests/texp2.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_exp2.
-Copyright (C) 2001 Free Software Foundation.
+Copyright 2001 Free Software Foundation.
Adapted from tarctan.c.
This file is part of the MPFR Library.
@@ -16,7 +16,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -39,12 +39,23 @@ main (int argc, char *argv[])
mpfr_init (x);
mpfr_init (y);
+ mpfr_set_prec (x, 53);
+ mpfr_set_prec (y, 53);
+ mpfr_set_d (x, -1683977482443233.0 / 2199023255552.0, GMP_RNDN);
+ mpfr_exp2 (y, x, GMP_RNDN);
+ if (mpfr_get_d1 (y) != 2.991959870867646566478e-231)
+ {
+ fprintf (stderr, "Error for x=-1683977482443233/2^41\n");
+ exit (1);
+ }
+
MPFR_CLEAR_NAN(x);
MPFR_SET_INF(x);
+ MPFR_SET_POS(x);
mpfr_exp2 (y, x, GMP_RNDN);
if(!MPFR_IS_INF(y))
{
- printf ("evaluation of function in INF does not return INF");
+ fprintf (stderr, "evaluation of function in INF does not return INF\n");
exit (1);
}
@@ -52,7 +63,7 @@ main (int argc, char *argv[])
mpfr_exp2 (y, x, GMP_RNDN);
if(!MPFR_IS_ZERO(y))
{
- printf ("evaluation of function in -INF does not return 0");
+ fprintf (stderr, "evaluation of function in -INF does not return 0\n");
exit (1);
}
@@ -60,7 +71,7 @@ main (int argc, char *argv[])
mpfr_exp2 (y, x, GMP_RNDN);
if(!MPFR_IS_NAN(y))
{
- printf ("evaluation of function in NAN does not return NAN");
+ fprintf (stderr, "evaluation of function in NaN does not return NaN\n");
exit (1);
}
diff --git a/mpfr/tests/texpm1.c b/mpfr/tests/texpm1.c
index f05f7d22a..c5afaa99a 100644
--- a/mpfr/tests/texpm1.c
+++ b/mpfr/tests/texpm1.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_expm1.
-Copyright (C) 2001 Free Software Foundation.
+Copyright 2001 Free Software Foundation.
Adapted from tsinh.c.
This file is part of the MPFR Library.
@@ -16,7 +16,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/tests/tfactorial.c b/mpfr/tests/tfactorial.c
index 4b81bb22a..06660fc8b 100644
--- a/mpfr/tests/tfactorial.c
+++ b/mpfr/tests/tfactorial.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_factorial.
-Copyright (C) 2001 Free Software Foundation.
+Copyright 2001 Free Software Foundation.
Adapted from tarctan.c.
This file is part of the MPFR Library.
@@ -16,7 +16,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/tests/tfma.c b/mpfr/tests/tfma.c
index d661e78a1..f196b50ea 100644
--- a/mpfr/tests/tfma.c
+++ b/mpfr/tests/tfma.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_fma.
-Copyright (C) 2001 Free Software Foundation.
+Copyright 2001 Free Software Foundation.
Adapted from tarctan.c.
This file is part of the MPFR Library.
@@ -16,7 +16,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -49,6 +49,19 @@ main (int argc, char *argv[])
mpfr_set_d (z, 0.375, GMP_RNDN);
mpfr_fma (s, x, y, z, GMP_RNDU); /* result is 0 */
+ mpfr_set_prec (x, 27);
+ mpfr_set_prec (y, 27);
+ mpfr_set_prec (z, 27);
+ mpfr_set_prec (s, 27);
+ mpfr_set_str_raw (x, "1.11111111111111111111111111e-1");
+ mpfr_set (y, x, GMP_RNDN);
+ mpfr_set_str_raw (z, "-1.00011110100011001011001001e-1");
+ if (mpfr_fma (s, x, y, z, GMP_RNDN) >= 0)
+ {
+ fprintf (stderr, "Wrong inexact flag for x=y=1-2^(-27)\n");
+ exit (1);
+ }
+
MPFR_SET_NAN(x);
mpfr_random(y);
mpfr_random(z);
@@ -294,6 +307,13 @@ main (int argc, char *argv[])
{
fprintf (stderr, "Wrong inexact flag for rnd=%s: expected %d, got %d\n",
mpfr_print_rnd_mode (rnd), compare, inexact);
+ fprintf (stderr, "x="); mpfr_out_str (stderr, 2, 0, x, GMP_RNDN);
+ fprintf (stderr, " y="); mpfr_out_str (stderr, 2, 0, y, GMP_RNDN);
+ fprintf (stderr, " z="); mpfr_out_str (stderr, 2, 0, z, GMP_RNDN);
+ fprintf (stderr, " s="); mpfr_out_str (stderr, 2, 0, s, GMP_RNDN);
+ fprintf (stderr, "\n");
+ fprintf (stderr, "z=%1.20e s=%1.20e\n", mpfr_get_d1 (z),
+ mpfr_get_d1 (s));
exit (1);
}
}
diff --git a/mpfr/tests/tgeneric.c b/mpfr/tests/tgeneric.c
index 8ce1153cb..cdccd5a9a 100644
--- a/mpfr/tests/tgeneric.c
+++ b/mpfr/tests/tgeneric.c
@@ -1,6 +1,6 @@
/* Generic test file for functions with one mpfr_t argument.
-Copyright (C) 2001 Free Software Foundation.
+Copyright 2001, 2002 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/tests/tget_d.c b/mpfr/tests/tget_d.c
index ab5d0d157..754fc74cb 100644
--- a/mpfr/tests/tget_d.c
+++ b/mpfr/tests/tget_d.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_get_d
-Copyright (C) 1999-2002 Free Software Foundation.
+Copyright 1999, 2000, 2001, 2002 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,25 +15,54 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
#include <stdio.h>
#include <stdlib.h>
+#include <float.h>
#include "gmp.h"
#include "gmp-impl.h"
#include "mpfr.h"
#include "mpfr-impl.h"
+#include "mpfr-test.h"
-#if 0
+void check_denorms _PROTO ((void));
-#define TEST
-#include "rnd_mode.c"
+void
+check_denorms ()
+{
+ mpfr_t x;
+ double d, dd;
+ unsigned long int n;
+
+ mpfr_init2 (x, 2);
+
+ d = DBL_MIN; /* 2^(-1022) */
+ mpfr_set_ui (x, 1, GMP_RNDN);
+ mpfr_div_2exp (x, x, 1022, GMP_RNDN); /* 2^(-1022) */
+ for (n=0; n<52; n++, d /= 2.0)
+ {
+ dd = mpfr_get_d1 (x);
+ if (d != dd) /* should be 0 or 2^(-1022-n) */
+ {
+ fprintf (stderr, "Wrong result for 2^(%ld), ", -1022-n);
+ fprintf (stderr, "got %.20e instead of %.20e\n", dd, d);
+ exit (1);
+ }
+ mpfr_div_2exp (x, x, 1, GMP_RNDN);
+ }
+
+ mpfr_clear (x);
+}
int
main (void)
{
+
+#ifdef HAVE_FENV_H
+
mpfr_t half, x, y;
mp_rnd_t rnd_mode;
@@ -44,17 +73,20 @@ main (void)
mpfr_init2(x, 128);
mpfr_init2(y, 128);
+ mpfr_test_init ();
+
for (rnd_mode = 0; rnd_mode <= 3; rnd_mode++)
{
int i, j, si, sj;
double di, dj;
- mpfr_set_machine_rnd_mode(rnd_mode);
+ mpfr_set_machine_rnd_mode (rnd_mode);
for (i = 1, di = 0.25; i < 127; i++, di *= 0.5)
for (si = 0; si <= 1; si++)
{
- mpfr_div_2ui(x, half, i, GMP_RNDZ);
+ mpfr_div_2ui (x, half, i, GMP_RNDZ);
(si ? mpfr_sub : mpfr_add)(x, half, x, GMP_RNDZ);
+ /* x = 1/2 +/- 1/2^(1+i) */
for (j = i+1, dj = di * 0.5; j < 128 && j < i+53; j++, dj *= 0.5)
for (sj = 0; sj <= 1; sj++)
{
@@ -62,10 +94,11 @@ main (void)
int exp;
char *f;
- mpfr_div_2ui(y, half, j, GMP_RNDZ);
+ mpfr_div_2ui (y, half, j, GMP_RNDZ);
(sj ? mpfr_sub : mpfr_add)(y, x, y, GMP_RNDZ);
- exp = (rand() % 47) - 23;
- mpfr_mul_2si(y, y, exp, GMP_RNDZ);
+ /* y = 1/2 +/- 1/2^(1+i) +/- 1/2^(1+j) */
+ exp = (LONG_RAND() % 47) - 23;
+ mpfr_mul_2si (y, y, exp, GMP_RNDZ);
if (mpfr_inexflag_p())
{
fprintf(stderr, "Error in tget_d: inexact flag for "
@@ -75,16 +108,16 @@ main (void)
}
dd = si != sj ? di - dj : di + dj;
d = si ? 0.5 - dd : 0.5 + dd;
- if ((rand() / 1024) & 1)
+ if ((LONG_RAND() / 1024) & 1)
{
- c = mpfr_get_d(y);
+ c = mpfr_get_d (y, rnd_mode);
f = "mpfr_get_d";
}
else
{
- exp = (rand() % 47) - 23;
- c = mpfr_get_d2(y, exp);
- f = "mpfr_get_d2";
+ exp = (LONG_RAND() % 47) - 23;
+ c = mpfr_get_d3 (y, exp, rnd_mode);
+ f = "mpfr_get_d3";
if (si) /* then real d < 0.5 */
d *= sj && i == 1 ? 4 : 2; /* normalize real d */
}
@@ -94,11 +127,13 @@ main (void)
d /= 1 << -exp;
if (c != d)
{
- fprintf(stderr, "Error in tget_d (%s) for "
- "(i,si,j,sj,rnd,exp) = (%d,%d,%d,%d,%d,%d)\n"
- "got %.17g instead of %.17g\n",
- f, i, si, j, sj, rnd_mode, exp, c, d);
- exit(1);
+ fprintf (stderr, "Error in tget_d (%s) for "
+ "(i,si,j,sj,rnd,exp) = (%d,%d,%d,%d,%d,%d)\n"
+ "got %.25Le instead of %.25Le\n"
+ "Difference: %.19e\n",
+ f, i, si, j, sj, rnd_mode, exp,
+ (long double) c, (long double) d, d - c);
+ exit (1);
}
}
}
@@ -107,13 +142,10 @@ main (void)
mpfr_clear(half);
mpfr_clear(x);
mpfr_clear(y);
- return 0;
-}
#endif
-int
-main (void)
-{
- return 0;
+ check_denorms ();
+
+ return 0;
}
diff --git a/mpfr/tests/tget_str.c b/mpfr/tests/tget_str.c
index 07ae5c1ae..7eceb19c0 100644
--- a/mpfr/tests/tget_str.c
+++ b/mpfr/tests/tget_str.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_get_str.
-Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+Copyright 1999, 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -23,10 +23,10 @@ MA 02111-1307, USA. */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
+#include <time.h>
#include "gmp.h"
#include "mpfr.h"
-#ifdef TEST
+#ifdef HAVE_FENV_H
#include "mpfr-test.h"
#endif
@@ -105,10 +105,11 @@ check_small (void)
int
main (int argc, char *argv[])
{
-#ifdef TEST
- int i; double d;
+#ifdef HAVE_FENV_H
+ int i;
+ double d;
- srand(getpid());
+ SEED_RAND (time(NULL));
for (i=0;i<100000;i++) {
do { d = drand(); } while (isnan(d));
check(d, GMP_RNDN);
diff --git a/mpfr/tests/thyperbolic.c b/mpfr/tests/thyperbolic.c
index f3f8cdcd8..2c8f19f13 100644
--- a/mpfr/tests/thyperbolic.c
+++ b/mpfr/tests/thyperbolic.c
@@ -1,6 +1,6 @@
/* Test file for hyperbolic function : mpfr_cosh, mpfr_sinh, mpfr_tanh, mpfr_acosh, mpfr_asinh, mpfr_atanh.
-Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+Copyright 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -14,7 +14,7 @@ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITYor FIT
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/tests/thypot.c b/mpfr/tests/thypot.c
index 42621c3e6..685597051 100644
--- a/mpfr/tests/thypot.c
+++ b/mpfr/tests/thypot.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_hypot.
-Copyright (C) 2001 Free Software Foundation.
+Copyright 2001 Free Software Foundation.
Adapted from tarctan.c.
This file is part of the MPFR Library.
@@ -16,7 +16,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/tests/tisnan.c b/mpfr/tests/tisnan.c
index f7410dc54..6c13c751e 100644
--- a/mpfr/tests/tisnan.c
+++ b/mpfr/tests/tisnan.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_nan_p, mpfr_inf_p and mpfr_number_p.
-Copyright (C) 2001 Free Software Foundation.
+Copyright 2001 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/tests/tlog.c b/mpfr/tests/tlog.c
index a3e2bc049..3a0dcd1c4 100644
--- a/mpfr/tests/tlog.c
+++ b/mpfr/tests/tlog.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_log.
-Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+Copyright 1999, 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,14 +15,14 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
-#include <unistd.h>
+#include <time.h>
#include "gmp.h"
#include "mpfr.h"
#include "mpfr-test.h"
@@ -49,8 +49,8 @@ drand_log (void)
i = (INT32*) &d;
do {
- i[0] = lrand48();
- i[1] = lrand48();
+ i[0] = LONG_RAND();
+ i[1] = LONG_RAND();
} while ((d<1e-153) || (d>1e153)); /* to avoid underflow or overflow
in double calculus in sqrt(u*v) */
return d;
@@ -67,7 +67,7 @@ check1 (double a, mp_rnd_t rnd_mode, double res1, int ck, int max_ulp)
int diff=0;
/* ck=1 iff res1 is certified correct */
-#ifdef TEST
+#ifdef HAVE_FENV_H
mpfr_set_machine_rnd_mode(rnd_mode);
#endif
if (ck==0 && res1==0.0) res1=log(a);
@@ -75,7 +75,7 @@ check1 (double a, mp_rnd_t rnd_mode, double res1, int ck, int max_ulp)
mpfr_init2(tres, 53);
mpfr_set_d(ta, a, GMP_RNDN);
mpfr_log(tres, ta, rnd_mode);
- res2=mpfr_get_d(tres);
+ res2=mpfr_get_d1 (tres);
mpfr_clear(ta); mpfr_clear(tres);
if (res1!=res2 && (!isnan(res1) || !isnan(res2))) {
@@ -119,8 +119,8 @@ check4 (int N)
mp_rnd_t rnd;
for(i=0;i<N;i++) {
- d=drand_log();
- rnd = rand() % 4;
+ d = drand_log ();
+ rnd = LONG_RAND() % 4;
cur=check1 (d, rnd, 0.0, 0, max);
if (cur<0)
cur = -cur;
@@ -142,9 +142,9 @@ slave (int N, int p)
mpfr_init2(ta, 53);
mpfr_init2(tres, p);
for(i=0;i<N;i++) {
- d=drand_log();
- mpfr_set_d(ta, d, GMP_RNDN);
- mpfr_log(tres, ta,rand() % 4 );
+ d = drand_log();
+ mpfr_set_d (ta, d, GMP_RNDN);
+ mpfr_log (tres, ta, LONG_RAND() % 4 );
}
mpfr_clear(ta); mpfr_clear(tres);
printf("fin\n");
@@ -247,7 +247,7 @@ special (void)
mpfr_init2 (y, 53);
mpfr_set_ui (x, 3, GMP_RNDD);
mpfr_log (y, x, GMP_RNDD);
- if (mpfr_get_d (y) != 1.09861228866810956) {
+ if (mpfr_get_d1 (y) != 1.09861228866810956) {
fprintf (stderr, "Error in mpfr_log(3) for GMP_RNDD\n");
exit (1);
}
@@ -269,9 +269,10 @@ special (void)
int
main (int argc, char *argv[])
{
- int N=0;
+ int N = 0;
+ double d;
- srand48(getpid());
+ SEED_RAND (time(NULL));
if (argc==4) { /* tlog x prec rnd */
check3(atof(argv[1]), atoi(argv[2]), atoi(argv[3]));
return 0;
@@ -304,14 +305,16 @@ main (int argc, char *argv[])
check2(44.0,GMP_RNDU,3.78418963391826146392e+00);
check2(1.01979300812244555452, GMP_RNDN, 1.95996734891603664741e-02);
/* bugs found by Vincent Lefe`vre */
- check2(0.99999599881598921769, GMP_RNDN, -4.0011920155404068690e-6);
+ d = -4723773766428415.0 / 1180591620717411303424.0;
+ check2(0.99999599881598921769, GMP_RNDN, d);
check2(9.99995576063808955247e-01, GMP_RNDZ, -4.42394597667932383816e-06);
check2(9.99993687357856209097e-01, GMP_RNDN, -6.31266206860017342601e-06);
check2(9.99995223520736886691e-01, GMP_RNDN, -4.77649067052670982220e-06);
check2(9.99993025794720935551e-01, GMP_RNDN, -6.97422959894716163837e-06);
check2(9.99987549017837484833e-01, GMP_RNDN, -1.24510596766369924330e-05);
check2(9.99985901426543311032e-01, GMP_RNDN, -1.40986728425098585229e-05);
- check2(9.99986053947420794330e-01, GMP_RNDN, -1.39461498263010849386e-05);
+ d = -8232353813100321.0 / 590295810358705651712.0;
+ check2(9.99986053947420794330e-01, GMP_RNDN, d);
check2(9.99971938247442126979e-01, GMP_RNDN, -2.80621462962173414790e-05);
/* other bugs found by Vincent Lefe`vre */
check2(1.18615436389927785905e+77, GMP_RNDN, 1.77469768607706015473e+02);
@@ -328,7 +331,8 @@ main (int argc, char *argv[])
check2(6.18784121531737948160e+19,GMP_RNDZ,4.55717030391710693493e+01);
check2(1.02560267603047283735e+00,GMP_RNDD,2.52804164149448735987e-02);
check2(7.53428236571286402512e+34,GMP_RNDZ,8.03073567492226345621e+01);
- check2(1.42470900831881198052e+49,GMP_RNDZ,1.13180637144887668910e+02);
+ d = 497773706319601.0 / 4398046511104.0;
+ check2(1.42470900831881198052e+49, GMP_RNDZ, d);
check2(1.08013816255293777466e+11,GMP_RNDN,2.54055249841782604392e+01);
check2(6.72783635300509015581e-37,GMP_RNDU,-8.32893948416799503320e+01);
@@ -348,7 +352,8 @@ main (int argc, char *argv[])
check2(2.22183639799464011100e-01,GMP_RNDN,-1.50425103275253957413e+00);
check2(2.27313466156682375540e+00,GMP_RNDD,8.21159787095675608448e-01);
check2(6.58057413965851156767e-01,GMP_RNDZ,-4.18463096196088235600e-01);
- check2(7.34302197248998461006e+43,GMP_RNDZ,1.01004909469513179942e+02);
+ d = 7107588635148285.0 / 70368744177664.0;
+ check2 (7.34302197248998461006e+43, GMP_RNDZ, d);
check2(6.09969788341579732815e+00,GMP_RNDD,1.80823924264386204363e+00);
}
diff --git a/mpfr/tests/tlog10.c b/mpfr/tests/tlog10.c
index 6d134321b..4f64ba115 100644
--- a/mpfr/tests/tlog10.c
+++ b/mpfr/tests/tlog10.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_log10.
-Copyright (C) 2001 Free Software Foundation.
+Copyright 2001, 2002 Free Software Foundation.
Adapted from tsinh.c.
This file is part of the MPFR Library.
@@ -16,7 +16,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -32,7 +32,29 @@ MA 02111-1307, USA. */
int
main (int argc, char *argv[])
{
+ mpfr_t x, y;
+ unsigned int n;
+
test_generic (2, 100, 100);
+ /* check log10(10^n)=n */
+ mpfr_init2 (x, 53);
+ mpfr_init2 (y, 53);
+ mpfr_set_ui (x, 1, GMP_RNDN);
+
+ for (n=1; n<=15; n++)
+ {
+ mpfr_mul_ui (x, x, 10, GMP_RNDN); /* x = 10^n */
+ mpfr_log10 (y, x, GMP_RNDN);
+ if (mpfr_get_d1 (y) != (double) n)
+ {
+ fprintf (stderr, "log10(10^n) <> n for n=%u\n", n);
+ exit (1);
+ }
+ }
+
+ mpfr_clear (x);
+ mpfr_clear (y);
+
return 0;
}
diff --git a/mpfr/tests/tlog1p.c b/mpfr/tests/tlog1p.c
index 9716f2e9c..738ad2706 100644
--- a/mpfr/tests/tlog1p.c
+++ b/mpfr/tests/tlog1p.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_log1p.
-Copyright (C) 2001 Free Software Foundation.
+Copyright 2001 Free Software Foundation.
Adapted from tsinh.c.
This file is part of the MPFR Library.
@@ -16,7 +16,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/tests/tlog2.c b/mpfr/tests/tlog2.c
index efe4f53a5..687ba0076 100644
--- a/mpfr/tests/tlog2.c
+++ b/mpfr/tests/tlog2.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_log2.
-Copyright (C) 2001 Free Software Foundation.
+Copyright 2001 Free Software Foundation.
Adapted from tsinh.c.
This file is part of the MPFR Library.
@@ -16,7 +16,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/tests/tmul.c b/mpfr/tests/tmul.c
index 5c49f869b..7b572a7f5 100644
--- a/mpfr/tests/tmul.c
+++ b/mpfr/tests/tmul.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_mul.
-Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+Copyright 1999, 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,13 +15,13 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
#include <stdio.h>
#include <stdlib.h>
-#include <unistd.h>
+#include <time.h>
#include "gmp.h"
#include "gmp-impl.h"
#include "mpfr.h"
@@ -52,11 +52,11 @@ check (double x, double y, mp_rnd_t rnd_mode, unsigned int px,
mpfr_set_d(xx, x, rnd_mode);
mpfr_set_d(yy, y, rnd_mode);
mpfr_mul(zz, xx, yy, rnd_mode);
-#ifdef TEST
+#ifdef HAVE_FENV_H
mpfr_set_machine_rnd_mode(rnd_mode);
#endif
z1 = (res==0.0) ? x*y : res;
- z2 = mpfr_get_d(zz);
+ z2 = mpfr_get_d1 (zz);
if (z1!=z2 && (z1>=MINNORM || z1<=-MINNORM)) {
printf("mpfr_mul ");
if (res==0.0) printf("differs from libm.a"); else printf("failed");
@@ -79,7 +79,7 @@ check53 (double x, double y, mp_rnd_t rnd_mode, double z1)
mpfr_set_d (xx, x, rnd_mode);
mpfr_set_d (yy, y, rnd_mode);
mpfr_mul (zz, xx, yy, rnd_mode);
- z2 = mpfr_get_d (zz);
+ z2 = mpfr_get_d1 (zz);
if (z1!=z2 && (!isnan(z1) || !isnan(z2))) {
printf("mpfr_mul failed for x=%1.20e y=%1.20e with rnd_mode=%s\n",
x, y, mpfr_print_rnd_mode(rnd_mode));
@@ -94,7 +94,8 @@ check53 (double x, double y, mp_rnd_t rnd_mode, double z1)
void
check24 (float x, float y, mp_rnd_t rnd_mode, float z1)
{
- float z2; mpfr_t xx, yy, zz;
+ float z2;
+ mpfr_t xx, yy, zz;
mpfr_init2 (xx, 24);
mpfr_init2 (yy, 24);
@@ -102,13 +103,17 @@ check24 (float x, float y, mp_rnd_t rnd_mode, float z1)
mpfr_set_d (xx, x, rnd_mode);
mpfr_set_d (yy, y, rnd_mode);
mpfr_mul (zz, xx, yy, rnd_mode);
- z2 = (float) mpfr_get_d (zz);
- if (z1!=z2) {
- printf("mpfr_mul failed for x=%1.0f y=%1.0f with prec=24 and rnd_mode=%s\n", x, y, mpfr_print_rnd_mode(rnd_mode));
- printf("libm.a gives %1.0f, mpfr_mul gives %1.0f\n", z1, z2);
- exit(1);
- }
- mpfr_clear(xx); mpfr_clear(yy); mpfr_clear(zz);
+ z2 = (float) mpfr_get_d1 (zz);
+ if (z1 != z2)
+ {
+ fprintf (stderr, "mpfr_mul failed for x=%1.0f y=%1.0f with prec=24 and"
+ "rnd=%s\n", x, y, mpfr_print_rnd_mode(rnd_mode));
+ fprintf (stderr, "libm.a gives %.10e, mpfr_mul gives %.10e\n", z1, z2);
+ exit (1);
+ }
+ mpfr_clear(xx);
+ mpfr_clear(yy);
+ mpfr_clear(zz);
}
/* the following examples come from the paper "Number-theoretic Test
@@ -116,6 +121,8 @@ check24 (float x, float y, mp_rnd_t rnd_mode, float z1)
void
check_float (void)
{
+ float z;
+
check24(8388609.0, 8388609.0, GMP_RNDN, 70368760954880.0);
check24(16777213.0, 8388609.0, GMP_RNDN, 140737479966720.0);
check24(8388611.0, 8388609.0, GMP_RNDN, 70368777732096.0);
@@ -128,7 +135,8 @@ check_float (void)
check24(8388609.0, 8388609.0, GMP_RNDZ, 70368760954880.0);
check24(16777213.0, 8388609.0, GMP_RNDZ, 140737471578112.0);
- check24(8388611.0, 8388609.0, GMP_RNDZ, 70368777732096.0);
+ z = 70368777732096.0;
+ check24(8388611.0, 8388609.0, GMP_RNDZ, z);
check24(12582911.0, 8388610.0, GMP_RNDZ, 105553124655104.0);
check24(12582914.0, 8388610.0, GMP_RNDZ, 105553158209536.0);
check24(13981013.0, 8388611.0, GMP_RNDZ, 117281271054336.0);
@@ -168,8 +176,8 @@ check_sign (void)
mpfr_set_d(a, -1.0, GMP_RNDN);
mpfr_set_d(b, 2.0, GMP_RNDN);
mpfr_mul(a, b, b, GMP_RNDN);
- if (mpfr_get_d(a) != 4.0) {
- fprintf(stderr,"2.0*2.0 gives %1.20e\n", mpfr_get_d(a)); exit(1);
+ if (mpfr_get_d1 (a) != 4.0) {
+ fprintf(stderr,"2.0*2.0 gives %1.20e\n", mpfr_get_d1 (a)); exit(1);
}
mpfr_clear(a); mpfr_clear(b);
}
@@ -209,7 +217,7 @@ check_exact (void)
{
mpfr_random (a);
mpfr_random (b);
- rnd = rand() % 4;
+ rnd = LONG_RAND() % 4;
inexact = mpfr_mul (c, a, b, rnd);
if (mpfr_mul (d, a, b, rnd)) /* should be always exact */
{
@@ -341,17 +349,22 @@ check_min(void)
int
main (int argc, char *argv[])
{
-#ifdef TEST
- double x, y, z; int i, prec, rnd_mode;
+#ifdef HAVE_FENV_H
+ double x, y, z;
+ int i, prec, rnd_mode;
+
+ mpfr_test_init ();
#endif
check_exact ();
check_float ();
- check53(0.0, 1.0/0.0, GMP_RNDN, 0.0/0.0);
- check53(1.0, 1.0/0.0, GMP_RNDN, 1.0/0.0);
- check53(-1.0, 1.0/0.0, GMP_RNDN, -1.0/0.0);
- check53(0.0/0.0, 0.0, GMP_RNDN, 0.0/0.0);
- check53(1.0, 0.0/0.0, GMP_RNDN, 0.0/0.0);
+#ifdef HAVE_INFS
+ check53 (0.0, DBL_POS_INF, GMP_RNDN, DBL_NAN);
+ check53(1.0, DBL_POS_INF, GMP_RNDN, DBL_POS_INF);
+ check53(-1.0, DBL_POS_INF, GMP_RNDN, DBL_NEG_INF);
+ check53(DBL_NAN, 0.0, GMP_RNDN, DBL_NAN);
+ check53(1.0, DBL_NAN, GMP_RNDN, DBL_NAN);
+#endif
check53(6.9314718055994530941514e-1, 0.0, GMP_RNDZ, 0.0);
check53(0.0, 6.9314718055994530941514e-1, GMP_RNDZ, 0.0);
check_sign();
@@ -376,8 +389,8 @@ main (int argc, char *argv[])
49, 3, 2, 0.09375);
check_max();
check_min();
-#ifdef TEST
- srand48(getpid());
+#ifdef HAVE_FENV_H
+ SEED_RAND (time(NULL));
prec = (argc<2) ? 53 : atoi(argv[1]);
rnd_mode = (argc<3) ? -1 : atoi(argv[2]);
for (i=0;i<1000000;) {
@@ -386,7 +399,7 @@ main (int argc, char *argv[])
z = x*y; if (z<0) z=-z;
if (z<1e+308 && z>1e-308) /* don't test overflow/underflow for now */
{ i++;
- check(x, y, (rnd_mode==-1) ? lrand48()%4 : rnd_mode,
+ check(x, y, (rnd_mode==-1) ? LONG_RAND()%4 : rnd_mode,
prec, prec, prec, 0.0);
}
}
diff --git a/mpfr/tests/tmul_2exp.c b/mpfr/tests/tmul_2exp.c
index b3812058b..c4e1ae1d2 100644
--- a/mpfr/tests/tmul_2exp.c
+++ b/mpfr/tests/tmul_2exp.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_mul_2exp.
-Copyright (C) 1999, 2001 Free Software Foundation.
+Copyright 1999, 2001, 2002 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -25,6 +25,7 @@ MA 02111-1307, USA. */
#include "gmp.h"
#include "mpfr.h"
#include "mpfr-impl.h"
+#include "mpfr-test.h"
/* checks that x*y gives the same results in double
and with mpfr with 53 bits of precision */
@@ -36,20 +37,20 @@ main (int argc, char *argv[])
mpfr_init2(w, 53);
- mpfr_set_d(w, 1.0/0.0, 0);
- mpfr_mul_2exp(w, w, 10, GMP_RNDZ);
+ mpfr_set_inf (w, 1);
+ mpfr_mul_2exp (w, w, 10, GMP_RNDZ);
if (!MPFR_IS_INF(w)) { fprintf(stderr, "Inf != Inf"); exit(-1); }
- mpfr_set_d(w, 0.0/0.0, 0);
- mpfr_mul_2exp(w, w, 10, GMP_RNDZ);
+ mpfr_set_nan (w);
+ mpfr_mul_2exp (w, w, 10, GMP_RNDZ);
if (!MPFR_IS_NAN(w)) { fprintf(stderr, "NaN != NaN"); exit(-1); }
+ SEED_RAND (time(NULL));
for (k = 0; k < 100000; k++) {
- srand48(time(NULL));
- x = drand48();
- mpfr_set_d(w, x, 0);
- mpfr_mul_2exp(w, w, 10, GMP_RNDZ);
- if (x != (z = mpfr_get_d(w)/1024))
+ x = DBL_RAND ();
+ mpfr_set_d (w, x, 0);
+ mpfr_mul_2exp (w, w, 10, GMP_RNDZ);
+ if (x != (z = mpfr_get_d1 (w)/1024))
{
fprintf(stderr, "%f != %f\n", x, z);
return -1;
@@ -57,7 +58,7 @@ main (int argc, char *argv[])
mpfr_set_d(w, x, 0);
mpfr_div_2exp(w, w, 10, GMP_RNDZ);
- if (x != (z = mpfr_get_d(w)*1024))
+ if (x != (z = mpfr_get_d1 (w)*1024))
{
fprintf(stderr, "%f != %f\n", x, z);
mpfr_clear(w);
diff --git a/mpfr/tests/tmul_ui.c b/mpfr/tests/tmul_ui.c
index 8ca7491b6..298d25d28 100644
--- a/mpfr/tests/tmul_ui.c
+++ b/mpfr/tests/tmul_ui.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_mul_ui.
-Copyright (C) 1999-2001 Free Software Foundation.
+Copyright 1999, 2000, 2001, 2002 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -26,6 +26,7 @@ MA 02111-1307, USA. */
#include "gmp-impl.h"
#include "mpfr.h"
#include "mpfr-impl.h"
+#include "mpfr-test.h"
void check_inexact _PROTO((mp_prec_t));
@@ -42,7 +43,7 @@ check_inexact (mp_prec_t p)
mpfr_init (y);
mpfr_init2 (z, p + mp_bits_per_limb);
mpfr_random (x);
- u = lrand48();
+ u = LONG_RAND();
if (mpfr_mul_ui (z, x, u, GMP_RNDN))
{
fprintf (stderr, "Error: result should be exact\n");
@@ -109,25 +110,25 @@ main (int argc, char *argv[])
}
- mpfr_set_d (x, 1.0/0.0, GMP_RNDZ);
+ mpfr_set_inf (x, 1);
mpfr_mul_ui (x, x, 3, GMP_RNDU);
- if (mpfr_get_d (x) != 1.0/0.0)
+ if (!mpfr_inf_p (x) || (mpfr_sgn (x) <= 0))
{
- fprintf (stderr, "Error in mpfr_mul_ui: Inf*3 does not give Inf\n");
+ fprintf (stderr, "Error in mpfr_mul_ui: +Inf*3 does not give +Inf\n");
exit (1);
}
- mpfr_set_d (x, -1.0/0.0, GMP_RNDZ);
+ mpfr_set_inf (x, -1);
mpfr_mul_ui (x, x, 3, GMP_RNDU);
- if (mpfr_get_d (x) != -1.0/0.0)
+ if (!mpfr_inf_p (x) || (mpfr_sgn (x) >= 0))
{
fprintf (stderr, "Error in mpfr_mul_ui: -Inf*3 does not give -Inf\n");
exit (1);
}
- mpfr_set_d (x, 0.0/0.0, GMP_RNDZ);
+ mpfr_set_nan (x);
mpfr_mul_ui (x, x, 3, GMP_RNDU);
- if (!isnan(mpfr_get_d(x)))
+ if (!mpfr_nan_p(x))
{
fprintf (stderr, "Error in mpfr_mul_ui: NaN*3 does not give NaN\n");
exit (1);
@@ -135,7 +136,7 @@ main (int argc, char *argv[])
mpfr_set_d (x, 1.0/3.0, GMP_RNDZ);
mpfr_mul_ui (x, x, 3, GMP_RNDU);
- if (mpfr_get_d (x) != 1.0)
+ if (mpfr_get_d1 (x) != 1.0)
{
fprintf (stderr, "Error in mpfr_mul_ui: U(Z(1/3)*3) does not give 1\n");
exit (1);
@@ -214,7 +215,7 @@ main (int argc, char *argv[])
{
mpfr_set_prec (y, yprec);
mpfr_mul_ui (y, x, 1, GMP_RNDN);
- if (mpfr_get_d (x) != mpfr_get_d (y))
+ if (mpfr_get_d1 (x) != mpfr_get_d1 (y))
{
fprintf (stderr, "multiplication by 1.0 fails for xprec=%u, yprec=%u\n", xprec, yprec);
printf ("expected "); mpfr_print_binary (x); putchar ('\n');
@@ -226,13 +227,13 @@ main (int argc, char *argv[])
mpfr_set_prec (x, 128);
mpfr_set_ui (x, 17, GMP_RNDN);
- mpfr_mul_ui (x, x, MP_LIMB_T_HIGHBIT, GMP_RNDN);
+ mpfr_mul_ui (x, x, ULONG_HIGHBIT, GMP_RNDN);
mpfr_set_prec (y, 128);
- mpfr_set_ui (y, MP_LIMB_T_HIGHBIT, GMP_RNDN);
+ mpfr_set_ui (y, ULONG_HIGHBIT, GMP_RNDN);
mpfr_mul_ui (y, y, 17, GMP_RNDN);
if (mpfr_cmp (x, y))
{
- printf ("Error for 17 * 2^MP_LIMB_T_HIGHBIT\n");
+ printf ("Error for 17 * ULONG_HIGHBIT\n");
exit (1);
}
diff --git a/mpfr/tests/tout_str.c b/mpfr/tests/tout_str.c
index 3668ca892..feb2cae00 100644
--- a/mpfr/tests/tout_str.c
+++ b/mpfr/tests/tout_str.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_out_str.
-Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+Copyright 1999, 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -24,7 +24,6 @@ MA 02111-1307, USA. */
#include <stdlib.h>
#include <string.h>
#include <time.h>
-#include <unistd.h>
#include "gmp.h"
#include "mpfr.h"
#include "mpfr-test.h"
@@ -130,22 +129,18 @@ main (int argc, char *argv[])
check(2.14478198760196000000e+16, GMP_RNDN, 10);
check(7.02293374921793516813e-84, GMP_RNDN, 10);
- /* This bombs on alphaev56-unknown-freebsd4.1 due to attempting to printf
- denormlaized numbers. */
-#if 0
/* random tests */
- srand(getpid());
+ SEED_RAND (time(NULL));
for (i=0;i<N;i++)
{
do
{
- d = drand();
+ d = drand ();
} while (isnan(d));
- r = rand() % 4;
- p = 2 + rand() % 35;
+ r = LONG_RAND() % 4;
+ p = 2 + LONG_RAND() % 35;
check (d, r, p);
}
-#endif
return 0;
}
diff --git a/mpfr/tests/tpow.c b/mpfr/tests/tpow.c
index b54a53679..5adc47209 100644
--- a/mpfr/tests/tpow.c
+++ b/mpfr/tests/tpow.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_pow and mpfr_pow_ui.
-Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
+Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -23,6 +23,8 @@ MA 02111-1307, USA. */
#include <stdlib.h>
#include "gmp.h"
#include "mpfr.h"
+#include "mpfr-impl.h"
+#include "mpfr-test.h"
void check_pow_ui _PROTO ((void));
void check_inexact _PROTO ((mp_prec_t));
@@ -45,19 +47,23 @@ check_pow_ui (void)
/* check large exponents */
mpfr_set_d (b, 1, GMP_RNDN);
- mpfr_pow_ui (a, b, (unsigned long) 4294967295, GMP_RNDN);
+ mpfr_pow_ui (a, b, 4294967295UL, GMP_RNDN);
- mpfr_set_d (a, -1.0/0.0, GMP_RNDN);
- mpfr_pow_ui (a, a, (unsigned long) 4049053855, GMP_RNDN);
- if (mpfr_get_d (a) != -1.0/0.0) {
- fprintf (stderr, "Error for (-Inf)^4049053855\n"); exit (1);
- }
+ mpfr_set_inf (a, -1);
+ mpfr_pow_ui (a, a, 4049053855UL, GMP_RNDN);
+ if (!mpfr_inf_p (a) || (mpfr_sgn (a) >= 0))
+ {
+ fprintf (stderr, "Error for (-Inf)^4049053855\n");
+ exit (1);
+ }
- mpfr_set_d (a, -1.0/0.0, GMP_RNDN);
+ mpfr_set_inf (a, -1);
mpfr_pow_ui (a, a, (unsigned long) 30002752, GMP_RNDN);
- if (mpfr_get_d (a) != 1.0/0.0) {
- fprintf (stderr, "Error for (-Inf)^30002752\n"); exit (1);
- }
+ if (!mpfr_inf_p (a) || (mpfr_sgn (a) <= 0))
+ {
+ fprintf (stderr, "Error for (-Inf)^30002752\n");
+ exit (1);
+ }
mpfr_clear (a);
mpfr_clear (b);
@@ -77,7 +83,7 @@ check_inexact (mp_prec_t p)
mpfr_init (z);
mpfr_init (t);
mpfr_random (x);
- u = lrand48() % 2;
+ u = LONG_RAND() % 2;
for (q=2; q<=p; q++)
for (rnd=0; rnd<4; rnd++)
{
diff --git a/mpfr/tests/tpow3.c b/mpfr/tests/tpow3.c
index 12b945e55..20715720e 100644
--- a/mpfr/tests/tpow3.c
+++ b/mpfr/tests/tpow3.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_pow.
-Copyright (C) 2001 Free Software Foundation.
+Copyright 2001 Free Software Foundation.
Adapted from tarctan.c.
This file is part of the MPFR Library.
@@ -16,7 +16,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/tests/trandom.c b/mpfr/tests/trandom.c
index 2c1396cee..54df59acc 100644
--- a/mpfr/tests/trandom.c
+++ b/mpfr/tests/trandom.c
@@ -1,6 +1,6 @@
/* Test file for the various mpfr_random fonctions.
-Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation.
+Copyright 1999, 2000, 2001, 2002 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -46,7 +46,7 @@ test_random (unsigned long nbtests, unsigned long prec, int verbose)
for (k = 0; k < nbtests; k++) {
mpfr_random(x);
- d = mpfr_get_d(x); av += d; var += d*d;
+ d = mpfr_get_d1 (x); av += d; var += d*d;
tab[(int)(size_tab * d)]++;
}
@@ -92,7 +92,7 @@ test_random2 (unsigned long nbtests, unsigned long prec, int verbose)
for (k = 0; k < nbtests; k++) {
mpfr_random2 (x, MPFR_ABSSIZE(x), 0);
- d = mpfr_get_d(x); av += d; var += d*d;
+ d = mpfr_get_d1 (x); av += d; var += d*d;
if (d < 1)
tab[(int)(size_tab * d)]++;
}
@@ -134,12 +134,12 @@ test_urandomb (unsigned long nbtests, unsigned long prec, int verbose)
tab = (int *) malloc (size_tab * sizeof(int));
for (k = 0; k < size_tab; ++k) tab[k] = 0;
- gmp_randinit(state, GMP_RAND_ALG_LC, 128);
- gmp_randseed_ui(state, (unsigned long int)time(NULL));
+ gmp_randinit (state, GMP_RAND_ALG_LC, 128);
+ gmp_randseed_ui (state, time(NULL));
for (k = 0; k < nbtests; k++) {
mpfr_urandomb(x, state);
- d = mpfr_get_d(x); av += d; var += d*d;
+ d = mpfr_get_d1 (x); av += d; var += d*d;
tab[(int)(size_tab * d)]++;
}
diff --git a/mpfr/tests/trint.c b/mpfr/tests/trint.c
index 9c5935490..6b0bd63fc 100644
--- a/mpfr/tests/trint.c
+++ b/mpfr/tests/trint.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_trunc, mpfr_floor, mpfr_ceil, mpfr_round.
-Copyright (C) 2002 Free Software Foundation.
+Copyright 2002 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -23,6 +23,7 @@ MA 02111-1307, USA. */
#include <stdlib.h>
#include "gmp.h"
#include "mpfr.h"
+#include "mpfr-test.h"
int
main (void)
@@ -44,7 +45,7 @@ main (void)
/* z has exactly s bits */
mpz_mul_2exp (z, z, 1);
- if (rand () % 2)
+ if (LONG_RAND () % 2)
mpz_add_ui (z, z, 1);
mpfr_set_prec (x, s);
mpfr_set_prec (t, s);
diff --git a/mpfr/tests/tround_prec.c b/mpfr/tests/tround_prec.c
index 72437f26a..419afa445 100644
--- a/mpfr/tests/tround_prec.c
+++ b/mpfr/tests/tround_prec.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_round_prec.
-Copyright (C) 1999-2002 Free Software Foundation.
+Copyright 1999, 2000, 2001, 2002 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -36,7 +36,7 @@ main (void)
if (mpfr_cmp_ui(x, 4))
{
fprintf (stderr, "Error in tround: got %1.1f instead of 4\n",
- mpfr_get_d (x));
+ mpfr_get_d1 (x));
exit (1);
}
@@ -47,7 +47,7 @@ main (void)
if (mpfr_cmp_ui(x, 5))
{
fprintf (stderr, "Error in tround: got %1.1f instead of 5\n",
- mpfr_get_d (x));
+ mpfr_get_d1 (x));
exit (1);
}
@@ -58,7 +58,7 @@ main (void)
if (mpfr_cmp_si(x, -5))
{
fprintf (stderr, "Error in tround: got %1.1f instead of -5\n",
- mpfr_get_d (x));
+ mpfr_get_d1 (x));
exit (1);
}
@@ -69,7 +69,7 @@ main (void)
if (mpfr_cmp_ui(x, 5))
{
fprintf (stderr, "Error in tround: got %1.1f instead of 5\n",
- mpfr_get_d (x));
+ mpfr_get_d1 (x));
exit (1);
}
diff --git a/mpfr/tests/tset.c b/mpfr/tests/tset.c
index 1ae5951d6..3905eb823 100644
--- a/mpfr/tests/tset.c
+++ b/mpfr/tests/tset.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_set.
-Copyright (C) 2001 Free Software Foundation.
+Copyright 2001 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -24,6 +24,7 @@ MA 02111-1307, USA. */
#include <stdlib.h>
#include "gmp.h"
#include "mpfr.h"
+#include "mpfr-test.h"
int
main (void)
@@ -54,7 +55,7 @@ main (void)
{
mpfr_set_prec (x, p);
mpfr_random (x);
- if (rand () % 2)
+ if (LONG_RAND () % 2)
mpfr_neg (x, x, GMP_RNDN);
for (q=2; q<2*p; q++)
{
diff --git a/mpfr/tests/tset_d.c b/mpfr/tests/tset_d.c
index 3a1ace898..dfaa4f4ef 100644
--- a/mpfr/tests/tset_d.c
+++ b/mpfr/tests/tset_d.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_set_d and mpfr_get_d.
-Copyright (C) 1999-2002 Free Software Foundation, Inc.
+Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,10 +15,11 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
+#include <float.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
@@ -29,74 +30,97 @@ MA 02111-1307, USA. */
int
main (int argc, char *argv[])
{
- mpfr_t x,y,z; unsigned long k,n; double d, dd;
-#ifdef __mips
- /* to get denormalized numbers on IRIX64 */
- union fpc_csr exp;
- exp.fc_word = get_fpc_csr();
- exp.fc_struct.flush = 0;
- set_fpc_csr(exp.fc_word);
-#endif
+ mpfr_t x, y, z;
+ unsigned long k, n;
+ double d, dd;
+
+ mpfr_test_init ();
+
+ mpfr_init2 (x, 2);
- mpfr_init2 (x, 2);
+ /* checks that denormalized are not flushed to zero */
+ d = DBL_MIN; /* 2^(-1022) */
+ for (n=0; n<52; n++, d /= 2.0)
+ if (d != 0.0) /* should be 2^(-1022-n) */
+ {
+ mpfr_set_d (x, d, GMP_RNDN);
+ if (mpfr_cmp_ui_2exp (x, 1, -1022-n))
+ {
+ fprintf (stderr, "Wrong result for d=2^(%ld), ", -1022-n);
+ fprintf (stderr, "got ");
+ mpfr_out_str (stderr, 10, 10, x, GMP_RNDN);
+ fprintf (stderr, "\n");
+ mpfr_print_binary (x); putchar ('\n');
+ exit (1);
+ }
+ }
/* checks that rounds to nearest sets the last
bit to zero in case of equal distance */
mpfr_set_d (x, 5.0, GMP_RNDN);
- if (mpfr_get_d (x) != 4.0)
+ if (mpfr_get_d1 (x) != 4.0)
{
fprintf (stderr, "Error in tset_d: got %g instead of 4.0\n",
- mpfr_get_d (x));
+ mpfr_get_d1 (x));
exit (1);
}
mpfr_set_d (x, -5.0, GMP_RNDN);
- if (mpfr_get_d (x) != -4.0)
+ if (mpfr_get_d1 (x) != -4.0)
{
fprintf (stderr, "Error in tset_d: got %g instead of -4.0\n",
- mpfr_get_d (x));
+ mpfr_get_d1 (x));
exit (1);
}
mpfr_set_d (x, 9.84891017624509146344e-01, GMP_RNDU);
- if (mpfr_get_d (x) != 1.0)
+ if (mpfr_get_d1 (x) != 1.0)
{
fprintf (stderr, "Error in tset_d: got %g instead of 1.0\n",
- mpfr_get_d (x));
+ mpfr_get_d1 (x));
exit (1);
}
mpfr_init2(z, 32);
mpfr_set_d(z, 1.0, 0);
- if (mpfr_get_d(z) != 1.0) {
+ if (mpfr_get_d1 (z) != 1.0) {
mpfr_print_binary(z); putchar('\n');
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);
- if (mpfr_get_d(x) != d) {
+ if (mpfr_get_d1 (x) != d) {
mpfr_print_binary(x); putchar('\n');
printf("Error: get_d o set_d <> identity for d = %1.20e %1.20e\n",d,
- mpfr_get_d(x)); exit(1);
+ mpfr_get_d1 (x)); exit(1);
}
- srand48(time(NULL));
+
+ SEED_RAND (time(NULL));
mpfr_set_d(x, 8.06294740693074521573e-310, 0);
d = -6.72658901114033715233e-165;
mpfr_set_d(x, d, 0);
- if (d != mpfr_get_d(x)) {
+ if (d != mpfr_get_d1 (x)) {
mpfr_print_binary(x); putchar('\n');
printf("Error: get_d o set_d <> identity for d = %1.20e %1.20e\n",d,
- mpfr_get_d(x)); exit(1);
+ mpfr_get_d1 (x)); exit(1);
}
n = (argc==1) ? 1000000 : atoi(argv[1]);
for (k = 1; k <= n; k++)
{
- d = drand();
- mpfr_set_d(x, d, 0);
- dd = mpfr_get_d(x);
+ do
+ {
+ d = drand();
+ }
+#ifdef HAVE_DENORMS
+ while (0);
+#else
+ while (ABS(d) <= 2.2e-307);
+#endif
+ mpfr_set_d (x, d, 0);
+ dd = mpfr_get_d1 (x);
if (d != dd && (!isnan(d) || !isnan(dd)))
{
fprintf(stderr,
- "Mismatch on : %1.18g != %1.18g\n", d, mpfr_get_d(x));
+ "Mismatch on : %1.18g != %1.18g\n", d, mpfr_get_d1 (x));
mpfr_print_binary(x); putchar('\n');
exit(1);
}
diff --git a/mpfr/tests/tset_f.c b/mpfr/tests/tset_f.c
index 59af6a940..0b7aba0d1 100644
--- a/mpfr/tests/tset_f.c
+++ b/mpfr/tests/tset_f.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_set_f.
-Copyright (C) 1999, 2001 Free Software Foundation, Inc.
+Copyright 1999, 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,15 +15,15 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
#include <stdio.h>
#include <stdlib.h>
+#include <time.h>
#include "gmp.h"
#include "mpfr.h"
-#include "time.h"
#include "mpfr-test.h"
int
@@ -43,9 +43,9 @@ main (void)
mpfr_set_prec (x, 100);
mpfr_set_f (x, y, GMP_RNDN);
- srandom((int)time(NULL));
+ SEED_RAND (time(NULL));
mpf_random2(y, 10, 0);
- mpfr_set_f(x, y, rand() & 3);
+ mpfr_set_f(x, y, LONG_RAND() & 3);
/* bug found by Jean-Pierre Merlet */
mpfr_set_prec(x, 256);
@@ -71,7 +71,7 @@ main (void)
for (k = 1; k <= 100000; k++)
{
- pr = 2 + (rand()&255);
+ pr = 2 + (LONG_RAND()&255);
mpf_set_prec (z, pr);
mpf_random2 (z, z->_mp_prec, 0);
mpfr_init2 (x, pr);
diff --git a/mpfr/tests/tset_q.c b/mpfr/tests/tset_q.c
index 9807c6ea8..57497843f 100644
--- a/mpfr/tests/tset_q.c
+++ b/mpfr/tests/tset_q.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_set_q.
-Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,15 +15,16 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
#include <stdio.h>
#include <stdlib.h>
-#include <unistd.h>
+#include <time.h>
#include "gmp.h"
#include "mpfr.h"
+#include "mpfr-test.h"
void check _PROTO((long int, long int, mp_rnd_t, double));
@@ -39,12 +40,12 @@ check (long int n, long int d, mp_rnd_t rnd, double y)
mpfr_init2 (t, mpfr_get_prec (x) + mp_bits_per_limb);
mpq_init (q);
mpq_set_si (q, n, d);
-#ifdef TEST
+#ifdef HAVE_FENV_H
mpfr_set_machine_rnd_mode (rnd);
y = (double) n / d;
#endif
inexact = mpfr_set_q (x, q, rnd);
- z = mpfr_get_d (x);
+ z = mpfr_get_d1 (x);
/* check values */
if (y != z)
@@ -79,18 +80,20 @@ check (long int n, long int d, mp_rnd_t rnd, double y)
int
main (void)
{
-#ifdef TEST
+#ifdef HAVE_FENV_H
long int i, n;
unsigned long int d;
double y;
unsigned char rnd;
- srand48(getpid());
+ mpfr_test_init ();
+
+ SEED_RAND(time(NULL));
for (i=0;i<1000000;i++) {
- n = lrand48();
- d = lrand48();
- if (lrand48()%2) n = -n;
- rnd = lrand48() % 4;
+ n = LONG_RAND();
+ d = LONG_RAND();
+ if (LONG_RAND()%2) n = -n;
+ rnd = LONG_RAND() % 4;
y = (double) n / d;
check(n, d, rnd, y);
}
diff --git a/mpfr/tests/tset_si.c b/mpfr/tests/tset_si.c
index 17ef0af63..afe00ec79 100644
--- a/mpfr/tests/tset_si.c
+++ b/mpfr/tests/tset_si.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_set_si and mpfr_set_ui.
-Copyright (C) 1999, 2001 Free Software Foundation, Inc.
+Copyright 1999, 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -37,7 +37,7 @@ main (int argc, char *argv[])
mpfr_init2(x, 100);
- srandom(time(NULL));
+ SEED_RAND (time(NULL));
N = (argc==1) ? 1000000 : atoi(argv[1]);
@@ -45,7 +45,7 @@ main (int argc, char *argv[])
{
z = random() - (1 << 30);
inex = mpfr_set_si(x, z, GMP_RNDZ);
- d = (long) mpfr_get_d(x);
+ d = (long) mpfr_get_d1 (x);
if (d != z) {
fprintf(stderr, "Error in mpfr_set_si: expected %ld got %ld\n", z, d); exit(1);
}
@@ -62,7 +62,7 @@ main (int argc, char *argv[])
{
zl = random();
inex = mpfr_set_ui (x, zl, GMP_RNDZ);
- dl = (unsigned long) mpfr_get_d (x);
+ dl = (unsigned long) mpfr_get_d1 (x);
if (dl != zl) {
fprintf(stderr, "Error in mpfr_set_ui: expected %lu got %lu\n", zl, dl); exit(1);
}
@@ -109,17 +109,17 @@ main (int argc, char *argv[])
mpfr_set_prec(x, 2);
inex = mpfr_set_si(x, 33096, GMP_RNDU);
- if (mpfr_get_d(x) != 49152.0 || inex <= 0)
+ if (mpfr_get_d1 (x) != 49152.0 || inex <= 0)
{
fprintf(stderr, "Error in mpfr_set_si, expected 49152, got %lu, inex %d\n",
- (unsigned long) mpfr_get_d(x), inex);
+ (unsigned long) mpfr_get_d1 (x), inex);
exit(1);
}
inex = mpfr_set_ui(x, 33096, GMP_RNDU);
- if (mpfr_get_d(x) != 49152.0)
+ if (mpfr_get_d1 (x) != 49152.0)
{
fprintf(stderr, "Error in mpfr_set_ui, expected 49152, got %lu, inex %d\n",
- (unsigned long) mpfr_get_d(x), inex);
+ (unsigned long) mpfr_get_d1 (x), inex);
exit(1);
}
@@ -139,6 +139,24 @@ main (int argc, char *argv[])
exit (1);
}
+ /* check potential bug in case mp_limb_t is unsigned */
+ mpfr_set_emax (0);
+ mpfr_set_si (x, -1, GMP_RNDN);
+ if (mpfr_sgn (x) >= 0)
+ {
+ fprintf (stderr, "mpfr_set_si (x, -1) fails\n");
+ exit (1);
+ }
+
+ mpfr_set_emax (5);
+ mpfr_set_prec (x, 2);
+ mpfr_set_si (x, -31, GMP_RNDN);
+ if (mpfr_sgn (x) >= 0)
+ {
+ fprintf (stderr, "mpfr_set_si (x, -31) fails\n");
+ exit (1);
+ }
+
mpfr_clear(x);
return 0;
diff --git a/mpfr/tests/tset_str.c b/mpfr/tests/tset_str.c
index 0477fcef3..75c595a34 100644
--- a/mpfr/tests/tset_str.c
+++ b/mpfr/tests/tset_str.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_set_str.
-Copyright (C) 1999, 2001 Free Software Foundation, Inc.
+Copyright 1999, 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -48,20 +48,20 @@ main (int argc, char *argv[])
return 0;
}
- srandom (time (NULL));
+ SEED_RAND (time(NULL));
nc = (argc > 1) ? atoi(argv[1]) : 53;
if (nc < 100)
nc = 100;
- bd = random() & 8;
+ bd = LONG_RAND() & 8;
str2 = str = (char *) malloc (nc * sizeof(char));
if (bd)
{
for(k = 1; k <= bd; k++)
- *(str2++) = (random() & 1) + '0';
+ *(str2++) = (LONG_RAND() & 1) + '0';
}
else
*(str2++) = '0';
@@ -69,10 +69,10 @@ main (int argc, char *argv[])
*(str2++) = '.';
for (k = 1; k < nc - 17 - bd; k++)
- *(str2++) = '0' + (random() & 1);
+ *(str2++) = '0' + (LONG_RAND() & 1);
*(str2++) = 'e';
- sprintf (str2, "%d", (int) random() - (1 << 30));
+ sprintf (str2, "%d", (int) LONG_RAND() - (1 << 30));
mpfr_init2 (x, nc + 10);
mpfr_set_str_raw (x, str);
@@ -99,7 +99,7 @@ main (int argc, char *argv[])
mpfr_set_str_raw (x, "+110101100.01010000101101000000100111001000101011101110E00");
mpfr_set_str_raw (x, "1.0");
- if (mpfr_get_d (x) != 1.0)
+ if (mpfr_get_d1 (x) != 1.0)
{
fprintf (stderr, "Error in mpfr_set_str_raw for s=1.0\n");
mpfr_clear(x);
@@ -110,7 +110,7 @@ main (int argc, char *argv[])
mpfr_set_str_raw (x, "+0000");
mpfr_set_str_raw (x, "+0000E0");
mpfr_set_str_raw (x, "0000E0");
- if (mpfr_get_d (x) != 0.0)
+ if (mpfr_get_d1 (x) != 0.0)
{
fprintf (stderr, "Error in mpfr_set_str_raw for s=0.0\n");
mpfr_clear (x);
@@ -131,8 +131,8 @@ main (int argc, char *argv[])
for (i=0;i<100000;i++)
{
mpfr_random (x);
- k = rand() % 4;
- logbase = (rand() % 5) + 1;
+ k = LONG_RAND() % 4;
+ logbase = (LONG_RAND() % 5) + 1;
base = 1 << logbase;
/* Warning: the number of bits needed to print exactly a number of
'prec' bits in base 2^logbase may be greater than ceil(prec/logbase),
diff --git a/mpfr/tests/tset_z.c b/mpfr/tests/tset_z.c
index c76c624c5..7c8309034 100644
--- a/mpfr/tests/tset_z.c
+++ b/mpfr/tests/tset_z.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_set_z.
-Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+Copyright 1999, 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,15 +15,16 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
#include <stdio.h>
#include <stdlib.h>
-#include <unistd.h>
+#include <time.h>
#include "gmp.h"
#include "mpfr.h"
+#include "mpfr-test.h"
void check _PROTO((long, unsigned char));
void check_large _PROTO((void));
@@ -36,7 +37,7 @@ check(long i, unsigned char rnd)
mpfr_init2(f, 53); mpz_init(z);
mpz_set_ui(z, i);
mpfr_set_z(f, z, rnd);
- if ((long)mpfr_get_d(f) != i) {
+ if ((long)mpfr_get_d1 (f) != i) {
printf("Error in mpfr_set_z for i=%ld rnd_mode=%d\n",i,rnd);
exit(1);
}
@@ -66,10 +67,10 @@ main (int argc, char *argv[])
long j;
check_large();
- srand(getpid());
+ SEED_RAND (time(NULL));
check(0, 0);
for (j=0; j<1000000; j++)
- check(lrand48(), rand()%4);
+ check(LONG_RAND(), LONG_RAND()%4);
return 0;
}
diff --git a/mpfr/tests/tsin.c b/mpfr/tests/tsin.c
index ec063a136..e199bd638 100644
--- a/mpfr/tests/tsin.c
+++ b/mpfr/tests/tsin.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_sin.
-Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+Copyright 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -24,6 +24,7 @@ MA 02111-1307, USA. */
#include <math.h>
#include "gmp.h"
#include "mpfr.h"
+#include "mpfr-impl.h"
#include "mpfr-test.h"
void check53 _PROTO ((double, double, mp_rnd_t));
@@ -37,13 +38,14 @@ check53 (double x, double sin_x, mp_rnd_t rnd_mode)
mpfr_init2 (s, 53);
mpfr_set_d (xx, x, rnd_mode); /* should be exact */
mpfr_sin (s, xx, rnd_mode);
- if (mpfr_get_d (s) != sin_x && (!isnan(sin_x) || !isnan(mpfr_get_d(s)))) {
- fprintf (stderr, "mpfr_sin failed for x=%1.20e, rnd=%s\n", x,
- mpfr_print_rnd_mode (rnd_mode));
- fprintf (stderr, "mpfr_sin gives sin(x)=%1.20e, expected %1.20e\n",
- mpfr_get_d (s), sin_x);
- exit(1);
- }
+ if (mpfr_get_d1 (s) != sin_x && (!isnan(sin_x) || !mpfr_nan_p(s)))
+ {
+ fprintf (stderr, "mpfr_sin failed for x=%1.20e, rnd=%s\n", x,
+ mpfr_print_rnd_mode (rnd_mode));
+ fprintf (stderr, "mpfr_sin gives sin(x)=%1.20e, expected %1.20e\n",
+ mpfr_get_d1 (s), sin_x);
+ exit(1);
+ }
mpfr_clear (xx);
mpfr_clear (s);
}
@@ -56,9 +58,11 @@ main (int argc, char *argv[])
{
mpfr_t x;
- check53(0.0/0.0, 0.0/0.0, GMP_RNDN);
- check53(1.0/0.0, 0.0/0.0, GMP_RNDN);
- check53(-1.0/0.0, 0.0/0.0, GMP_RNDN);
+#ifdef HAVE_INFS
+ check53 (DBL_NAN, DBL_NAN, GMP_RNDN);
+ check53 (DBL_POS_INF, DBL_NAN, GMP_RNDN);
+ check53 (DBL_NEG_INF, DBL_NAN, GMP_RNDN);
+#endif
/* worst case from PhD thesis of Vincent Lefe`vre: x=8980155785351021/2^54 */
check53 (4.984987858808754279e-1, 4.781075595393330379e-1, GMP_RNDN);
check53 (4.984987858808754279e-1, 4.781075595393329824e-1, GMP_RNDD);
@@ -75,7 +79,7 @@ main (int argc, char *argv[])
mpfr_set_d (x, 0.5, GMP_RNDN);
mpfr_sin (x, x, GMP_RNDD);
- if (mpfr_get_d(x) != 0.375)
+ if (mpfr_get_d1 (x) != 0.375)
{
fprintf (stderr, "mpfr_sin(0.5, GMP_RNDD) failed with precision=2\n");
exit (1);
diff --git a/mpfr/tests/tsinh.c b/mpfr/tests/tsinh.c
index d1cd127cd..813c9216c 100644
--- a/mpfr/tests/tsinh.c
+++ b/mpfr/tests/tsinh.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_sinh.
-Copyright (C) 2001 Free Software Foundation.
+Copyright 2001 Free Software Foundation.
Adapted from tarctan.c.
This file is part of the MPFR Library.
@@ -16,7 +16,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/tests/tsqrt.c b/mpfr/tests/tsqrt.c
index 0ac666758..bf6f1f5e5 100644
--- a/mpfr/tests/tsqrt.c
+++ b/mpfr/tests/tsqrt.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_sqrt.
-Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+Copyright 1999, 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,13 +15,14 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
+#include <time.h>
#include "gmp.h"
#include "gmp-impl.h"
#include "mpfr.h"
@@ -38,6 +39,7 @@ void check24 _PROTO((float, mp_rnd_t, float));
void check_float _PROTO((void));
void special _PROTO((void));
void check_inexact _PROTO((mp_prec_t));
+void check_nan _PROTO((void));
void
check3 (double a, mp_rnd_t rnd_mode, double Q)
@@ -47,7 +49,7 @@ check3 (double a, mp_rnd_t rnd_mode, double Q)
ck = (Q!=-1.0); /* if ck=1, then Q is certified correct */
mpfr_init2(q, 53);
mpfr_set_d(q, a, rnd_mode);
-#ifdef TEST
+#ifdef HAVE_FENV_H
mpfr_set_machine_rnd_mode(rnd_mode);
#endif
mpfr_sqrt(q, q, rnd_mode);
@@ -60,7 +62,7 @@ check3 (double a, mp_rnd_t rnd_mode, double Q)
}
}
- Q2 = mpfr_get_d(q);
+ Q2 = mpfr_get_d1 (q);
if (Q!=Q2 && (!isnan(Q) || !isnan(Q2))) {
u = ulp(Q2,Q);
if (ck) {
@@ -109,7 +111,7 @@ check24 (float a, mp_rnd_t rnd_mode, float Q)
mpfr_init2(q, 24);
mpfr_set_d(q, a, rnd_mode);
mpfr_sqrt(q, q, rnd_mode);
- Q2 = mpfr_get_d(q);
+ Q2 = mpfr_get_d1 (q);
if (Q!=Q2) {
printf("mpfr_sqrt failed for a=%1.10e, prec=24, rnd_mode=%s\n",
a, mpfr_print_rnd_mode(rnd_mode));
@@ -196,7 +198,7 @@ special (void)
mpfr_set_ui (z, 1, GMP_RNDN);
mpfr_add_one_ulp (z, GMP_RNDN);
mpfr_sqrt (x, z, GMP_RNDU);
- if (mpfr_get_d (x) != 1.5)
+ if (mpfr_get_d1 (x) != 1.5)
{
fprintf (stderr, "Error: sqrt(1+ulp(1), up) should give 1.5 (prec=%u)\n", (unsigned) p);
printf ("got "); mpfr_print_binary (x); putchar ('\n');
@@ -222,7 +224,7 @@ special (void)
mpfr_sqrt (z, x, GMP_RNDN);
if (mpfr_cmp_ui (z, 0) < 0) {
fprintf (stderr, "Error: square root of %e gives %e\n",
- mpfr_get_d (x), mpfr_get_d (z));
+ mpfr_get_d1 (x), mpfr_get_d1 (z));
exit (1);
}
@@ -248,7 +250,7 @@ check_inexact (mp_prec_t p)
mpfr_init2 (y, p);
mpfr_init2 (z, 2*p);
mpfr_random (x);
- rnd = rand() % 4;
+ rnd = LONG_RAND() % 4;
inexact = mpfr_sqrt (y, x, rnd);
if (mpfr_mul (z, y, y, rnd)) /* exact since prec(z) = 2*prec(y) */
{
@@ -324,31 +326,33 @@ main (void)
double a;
mp_prec_t p;
int k;
+#ifdef HAVE_FENV_H
+ int i;
- check_nan ();
+ mpfr_test_init ();
-#ifdef TEST
- int i;
-#ifdef __mips
- /* to get denormalized numbers on IRIX64 */
- union fpc_csr exp;
- exp.fc_word = get_fpc_csr();
- exp.fc_struct.flush = 0;
- set_fpc_csr(exp.fc_word);
+ SEED_RAND (time(NULL));
+ for (i=0;i<100000;i++)
+ {
+ a = drand();
+ if (a < 0.0) a = -a; /* ensures a is positive */
+ check (a, LONG_RAND() % 4);
+ }
#endif
+ check_nan ();
- srand(getpid());
- for (i=0;i<100000;i++) {
- a = drand();
- if (a < 0.0) a = -a; /* ensures a is positive */
- check(a, rand() % 4);
- }
-#endif
for (p=2; p<200; p++)
for (k=0; k<200; k++)
check_inexact (p);
special ();
check_float();
+#ifdef HAVE_INFS
+ check3 (DBL_NAN, GMP_RNDN, DBL_NAN);
+ check3 (-1.0, GMP_RNDN, DBL_NAN);
+ check3 (DBL_POS_INF, GMP_RNDN, DBL_POS_INF);
+ check3 (DBL_NEG_INF, GMP_RNDN, DBL_NAN);
+#endif
+ check3(-0.0, GMP_RNDN, 0.0);
check4(6.37983013646045901440e+32, GMP_RNDN, "5.9bc5036d09e0c@13");
check4(1.0, GMP_RNDN, "1");
check4(1.0, GMP_RNDZ, "1");
diff --git a/mpfr/tests/tsqrt_ui.c b/mpfr/tests/tsqrt_ui.c
index 3206d49e2..f3c7efabf 100644
--- a/mpfr/tests/tsqrt_ui.c
+++ b/mpfr/tests/tsqrt_ui.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_sqrt_ui.
-Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
+Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,13 +15,14 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
+#include <time.h>
#include "gmp.h"
#include "mpfr.h"
#include "mpfr-test.h"
@@ -36,13 +37,13 @@ check (unsigned long a, mp_rnd_t rnd_mode, double Q)
mpfr_t q; double Q2; int u, ck;
mpfr_init2(q, 53);
-#ifdef TEST
+#ifdef HAVE_FENV_H
mpfr_set_machine_rnd_mode(rnd_mode);
#endif
mpfr_sqrt_ui(q, a, rnd_mode);
ck = (Q >= 0.0);
if (!ck) Q = sqrt(1.0 * a);
- Q2 = mpfr_get_d(q);
+ Q2 = mpfr_get_d1 (q);
if (Q!=Q2 && (!isnan(Q) || !isnan(Q2))) {
u = ulp(Q2,Q);
if (ck) printf("mpfr_sqrt_ui failed");
@@ -58,25 +59,23 @@ check (unsigned long a, mp_rnd_t rnd_mode, double Q)
int
main (void)
{
-#ifdef TEST
- int i; unsigned long a;
-#ifdef __mips
- /* to get denormalized numbers on IRIX64 */
- union fpc_csr exp;
- exp.fc_word = get_fpc_csr();
- exp.fc_struct.flush = 0;
- set_fpc_csr(exp.fc_word);
-#endif
+#ifdef HAVE_FENV_H
+ int i;
+ unsigned long a;
- srand(getpid());
- for (i=0;i<1000000;i++) {
- a = lrand48();
- /* machine arithmetic must agree if a <= 2.0^53 */
- if (1.0*a < 9007199254872064.0) check(a, rand() % 4, -1.0);
- }
+ mpfr_test_init ();
+
+ SEED_RAND (time(NULL));
+ for (i=0;i<1000000;i++)
+ {
+ a = LONG_RAND();
+ /* machine arithmetic must agree if a <= 2.0^53 */
+ if (1.0*a < 9007199254872064.0)
+ check(a, LONG_RAND() % 4, -1.0);
+ }
#endif
- check(0, GMP_RNDN, 0.0);
- check(2116118, GMP_RNDU, 1.45468828276026215e3);
+ check (0, GMP_RNDN, 0.0);
+ check (2116118, GMP_RNDU, 1.45468828276026215e3);
return 0;
}
diff --git a/mpfr/tests/tsub.c b/mpfr/tests/tsub.c
index 282b1a0af..785dea183 100644
--- a/mpfr/tests/tsub.c
+++ b/mpfr/tests/tsub.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_sub.
-Copyright (C) 2001 Free Software Foundation.
+Copyright 2001 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -169,7 +169,7 @@ check_diverse (void)
/* check in-place operations */
mpfr_set_d (x, 1.0, GMP_RNDN);
mpfr_sub (x, x, x, GMP_RNDN);
- if (mpfr_get_d (x) != 0.0)
+ if (mpfr_get_d1 (x) != 0.0)
{
fprintf (stderr, "Error for mpfr_add (x, x, x, GMP_RNDN) with x=1.0\n");
exit (1);
@@ -182,7 +182,7 @@ check_diverse (void)
mpfr_set_d (y, 2.32221184180698677665e+05, GMP_RNDN);
mpfr_sub (z, x, y, GMP_RNDN);
res = 1229085880.815819263458251953125;
- got = mpfr_get_d (z);
+ got = mpfr_get_d1 (z);
if (got != res)
{
fprintf (stderr, "Error in mpfr_sub (1.22e9 - 2.32e5)\n");
@@ -306,7 +306,7 @@ check_two_sum (mp_prec_t p)
mpfr_random (y);
if (mpfr_cmp_abs (x, y) < 0)
mpfr_swap (x, y);
- rnd = rand() % 4;
+ rnd = LONG_RAND() % 4;
rnd = GMP_RNDN;
inexact = mpfr_sub (u, x, y, GMP_RNDN);
mpfr_sub (v, u, x, GMP_RNDN);
@@ -363,7 +363,7 @@ check_inexact (void)
: MPFR_EXP(u)-MPFR_EXP(x);
pz = pz + MAX(MPFR_PREC(x), MPFR_PREC(u));
mpfr_set_prec (z, pz);
- rnd = rand () % 4;
+ rnd = LONG_RAND () % 4;
if (mpfr_sub (z, x, u, rnd))
{
fprintf (stderr, "z <- x - u should be exact\n");
diff --git a/mpfr/tests/tsub_ui.c b/mpfr/tests/tsub_ui.c
index 5436f3b17..eccc97dc4 100644
--- a/mpfr/tests/tsub_ui.c
+++ b/mpfr/tests/tsub_ui.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_sub_ui
-Copyright (C) 2000, 2001, 2002 Free Software Foundation.
+Copyright 2000, 2001, 2002 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,25 +15,22 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
+#include <time.h>
#include "gmp.h"
#include "mpfr.h"
#include "mpfr-impl.h"
-#ifdef __mips
-#include <sys/fpu.h>
-#endif
+#include "mpfr-test.h"
void check_two_sum _PROTO ((mp_prec_t));
void check3 _PROTO ((double, unsigned long, mp_rnd_t, double));
-#define ABS(x) (((x)>0) ? (x) : (-x))
-
#define check(x,y,r) check3(x,y,r,0.0)
/* checks that x+y gives the same results in double
@@ -50,11 +47,11 @@ check3 (double x, unsigned long y, mp_rnd_t rnd_mode, double z1)
mpfr_set_prec(zz, 53);
mpfr_set_d(xx, x, rnd_mode);
mpfr_sub_ui(zz, xx, y, rnd_mode);
-#ifdef TEST
+#ifdef HAVE_FENV_H
mpfr_set_machine_rnd_mode(rnd_mode);
#endif
if (z1==0.0) z1 = x-y;
- z2 = mpfr_get_d(zz);
+ z2 = mpfr_get_d1 (zz);
if (z1!=z2 && !(isnan(z1) && isnan(z2))) {
printf("expected sum is %1.20e, got %1.20e\n",z1,z2);
printf("mpfr_sub_ui failed for x=%1.20e y=%lu with rnd_mode=%s\n",
@@ -82,11 +79,11 @@ check_two_sum (mp_prec_t p)
mpfr_init2 (w, p);
do
{
- x = lrand48 ();
+ x = LONG_RAND ();
}
while (x < 1);
mpfr_random (y);
- rnd = rand() % 4;
+ rnd = LONG_RAND() % 4;
rnd = GMP_RNDN;
inexact = mpfr_sub_ui (u, y, x, GMP_RNDN);
mpfr_add_ui (v, u, x, GMP_RNDN);
@@ -117,25 +114,20 @@ main (int argc, char *argv[])
{
mp_prec_t p;
int k;
-#ifdef __mips
- /* to get denormalized numbers on IRIX64 */
- union fpc_csr exp;
- exp.fc_word = get_fpc_csr();
- exp.fc_struct.flush = 0;
- set_fpc_csr(exp.fc_word);
-#endif
-#ifdef TEST
+#ifdef HAVE_FENV_H
double x; unsigned long y, N; int i,rnd_mode,rnd;
- srand(getpid());
+ mpfr_test_init ();
+
+ SEED_RAND (time(NULL));
N = (argc<2) ? 1000000 : atoi(argv[1]);
rnd_mode = (argc<3) ? -1 : atoi(argv[2]);
for (i=0;i<1000000;i++) {
- x = drand48();
- y = lrand48();
+ x = drand();
+ y = LONG_RAND();
if (ABS(x)>2.2e-307 && x+y<1.7e+308 && x+y>-1.7e308) {
/* avoid denormalized numbers and overflows */
- rnd = (rnd_mode==-1) ? lrand48()%4 : rnd_mode;
+ rnd = (rnd_mode==-1) ? LONG_RAND()%4 : rnd_mode;
check(x, y, rnd);
}
}
@@ -144,10 +136,14 @@ main (int argc, char *argv[])
for (p=2; p<200; p++)
for (k=0; k<200; k++)
check_two_sum (p);
- check3(0.9999999999, 1, GMP_RNDN, -1.000000082740370999e-10);
- check3(0.0/0.0, 1, GMP_RNDN, 0.0/0.0);
- check3(1.0/0.0, 1, GMP_RNDN, 1.0/0.0);
- check3(-1.0/0.0, 1, GMP_RNDN, -1.0/0.0);
+
+ check3 (0.9999999999, 1, GMP_RNDN, -56295.0 / 562949953421312.0);
+#ifdef HAVE_INFS
+ check3 (DBL_NAN, 1, GMP_RNDN, DBL_NAN);
+ check3 (DBL_POS_INF, 1, GMP_RNDN, DBL_POS_INF);
+ check3 (DBL_NEG_INF, 1, GMP_RNDN, DBL_NEG_INF);
+#endif
+
return 0;
}
diff --git a/mpfr/tests/tswap.c b/mpfr/tests/tswap.c
index b397c9742..4088d8851 100644
--- a/mpfr/tests/tswap.c
+++ b/mpfr/tests/tswap.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_swap.
-Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+Copyright 2000, 2001 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -35,7 +35,7 @@ main (void)
mpfr_set_d (v, 9007199254740991.0, GMP_RNDN); /* 2^53 - 1 */
mpfr_swap (u, v);
mpfr_swap (u, v);
- if (mpfr_cmp_ui (u, 16777215) || (mpfr_get_d (v) != 9007199254740991.0)) {
+ if (mpfr_cmp_ui (u, 16777215) || (mpfr_get_d1 (v) != 9007199254740991.0)) {
fprintf (stderr, "Error in mpfr_swap\n");
exit (1);
}
diff --git a/mpfr/tests/ttan.c b/mpfr/tests/ttan.c
index eb2cf3859..627bc6201 100644
--- a/mpfr/tests/ttan.c
+++ b/mpfr/tests/ttan.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_tan.
-Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+Copyright 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -24,6 +24,7 @@ MA 02111-1307, USA. */
#include <math.h>
#include "gmp.h"
#include "mpfr.h"
+#include "mpfr-impl.h"
#include "mpfr-test.h"
void check53 _PROTO ((double, double, mp_rnd_t));
@@ -37,11 +38,11 @@ check53 (double x, double tan_x, mp_rnd_t rnd_mode)
mpfr_init2 (s, 53);
mpfr_set_d (xx, x, rnd_mode); /* should be exact */
mpfr_tan (s, xx, rnd_mode);
- if (mpfr_get_d (s) != tan_x && (!isnan(tan_x) || !isnan(mpfr_get_d(s)))) {
+ if (mpfr_get_d1 (s) != tan_x && (!isnan(tan_x) || !mpfr_nan_p(s))) {
fprintf (stderr, "mpfr_tan failed for x=%1.20e, rnd=%s\n", x,
mpfr_print_rnd_mode (rnd_mode));
fprintf (stderr, "mpfr_tan gives tan(x)=%1.20e, expected %1.20e\n",
- mpfr_get_d (s), tan_x);
+ mpfr_get_d1 (s), tan_x);
exit(1);
}
mpfr_clear (xx);
@@ -55,20 +56,58 @@ int
main(int argc, char *argv[])
{
mpfr_t x;
+ unsigned int i;
+ unsigned int prec[10] = {14, 15, 19, 22, 23, 24, 25, 40, 41, 52};
+ unsigned int prec2[10] = {4, 5, 6, 19, 70, 95, 100, 106, 107, 108};
- check53(0.0/0.0, 0.0/0.0, GMP_RNDN);
- check53(1.0/0.0, 0.0/0.0, GMP_RNDN);
- check53(-1.0/0.0, 0.0/0.0, GMP_RNDN);
+#ifdef HAVE_INFS
+ check53 (DBL_NAN, DBL_NAN, GMP_RNDN);
+ check53 (DBL_POS_INF, DBL_NAN, GMP_RNDN);
+ check53 (DBL_NEG_INF, DBL_NAN, GMP_RNDN);
+#endif
mpfr_init (x);
+
mpfr_set_prec (x, 2);
mpfr_set_d (x, 0.5, GMP_RNDN);
mpfr_tan (x, x, GMP_RNDD);
- if (mpfr_get_d(x) != 0.5)
+ if (mpfr_get_d1 (x) != 0.5)
{
fprintf (stderr, "mpfr_tan(0.5, GMP_RNDD) failed\n");
+ fprintf (stderr, "expected 0.5, got %f\n", mpfr_get_d1 (x));
exit (1);
}
+
+ /* check that tan(3*Pi/4) ~ -1 */
+ for (i=0; i<10; i++)
+ {
+ mpfr_set_prec (x, prec[i]);
+ mpfr_const_pi (x, GMP_RNDN);
+ mpfr_mul_ui (x, x, 3, GMP_RNDN);
+ mpfr_div_ui (x, x, 4, GMP_RNDN);
+ mpfr_tan (x, x, GMP_RNDN);
+ if (mpfr_cmp_si (x, -1))
+ {
+ fprintf (stderr, "tan(3*Pi/4) fails for prec=%u\n", prec[i]);
+ exit (1);
+ }
+ }
+
+ /* check that tan(7*Pi/4) ~ -1 */
+ for (i=0; i<10; i++)
+ {
+ mpfr_set_prec (x, prec2[i]);
+ mpfr_const_pi (x, GMP_RNDN);
+ mpfr_mul_ui (x, x, 7, GMP_RNDN);
+ mpfr_div_ui (x, x, 4, GMP_RNDN);
+ mpfr_tan (x, x, GMP_RNDN);
+ if (mpfr_cmp_si (x, -1))
+ {
+ fprintf (stderr, "tan(3*Pi/4) fails for prec=%u\n", prec2[i]);
+ exit (1);
+ }
+ }
+
mpfr_clear (x);
test_generic (2, 100, 100);
diff --git a/mpfr/tests/ttanh.c b/mpfr/tests/ttanh.c
index 0a1fad746..bdb3bcedb 100644
--- a/mpfr/tests/ttanh.c
+++ b/mpfr/tests/ttanh.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_tanh.
-Copyright (C) 2001 Free Software Foundation.
+Copyright 2001 Free Software Foundation.
Adapted from tarctan.c.
This file is part of the MPFR Library.
@@ -16,7 +16,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/tests/ttrunc.c b/mpfr/tests/ttrunc.c
index 1f5338409..c829964fe 100644
--- a/mpfr/tests/ttrunc.c
+++ b/mpfr/tests/ttrunc.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_trunc, mpfr_ceil, mpfr_floor.
-Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
+Copyright 1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
@@ -42,23 +42,23 @@ main (void)
mpfr_set_d(x, 0.5, GMP_RNDN);
mpfr_ceil(y, x);
- if (mpfr_get_d(y) != 1.0) {
+ if (mpfr_get_d1 (y) != 1.0) {
fprintf(stderr, "Error in mpfr_ceil for x=0.5: expected 1.0, got %f\n",
- mpfr_get_d(y)); exit(1);
+ mpfr_get_d1 (y)); exit(1);
}
mpfr_set_d(x, 0.0, GMP_RNDN);
mpfr_ceil(y, x);
- if (mpfr_get_d(y) != 0.0) {
+ if (mpfr_get_d1 (y) != 0.0) {
fprintf(stderr, "Error in mpfr_ceil for x=0.0: expected 0.0, got %f\n",
- mpfr_get_d(y)); exit(1);
+ mpfr_get_d1 (y)); exit(1);
}
mpfr_set_d(x, 1.0, GMP_RNDN);
mpfr_ceil(y, x);
- if (mpfr_get_d(y) != 1.0) {
+ if (mpfr_get_d1 (y) != 1.0) {
fprintf(stderr, "Error in mpfr_ceil for x=1.0: expected 1.0, got %f\n",
- mpfr_get_d(y)); exit(1);
+ mpfr_get_d1 (y)); exit(1);
}
for (j=0;j<1000;j++) {
diff --git a/mpfr/tests/tui_div.c b/mpfr/tests/tui_div.c
index 3d01350a6..770faed5b 100644
--- a/mpfr/tests/tui_div.c
+++ b/mpfr/tests/tui_div.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_ui_div.
-Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
+Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,13 +15,14 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
+#include <time.h>
#include "gmp.h"
#include "gmp-impl.h"
#include "mpfr.h"
@@ -30,6 +31,7 @@ MA 02111-1307, USA. */
void check _PROTO((unsigned long, double, mp_rnd_t, double));
void check_inexact _PROTO((void));
+void check_nan _PROTO((void));
/* checks that y/x gives the same results in double
and with mpfr with 53 bits of precision */
@@ -42,11 +44,11 @@ check (unsigned long y, double x, mp_rnd_t rnd_mode, double z1)
mpfr_init2(zz, 53);
mpfr_set_d(xx, x, rnd_mode);
mpfr_ui_div(zz, y, xx, rnd_mode);
-#ifdef TEST
+#ifdef HAVE_FENV_H
mpfr_set_machine_rnd_mode(rnd_mode);
#endif
if (z1==0.0) z1 = y/x;
- z2 = mpfr_get_d(zz);
+ z2 = mpfr_get_d1 (zz);
if (z1!=z2 && !(isnan(z1) && isnan(z2))) {
printf("expected quotient is %1.20e, got %1.20e\n",z1,z2);
printf("mpfr_ui_div failed for y=%lu x=%1.20e with rnd_mode=%s\n",
@@ -74,7 +76,7 @@ check_inexact (void)
{
mpfr_set_prec (x, px);
mpfr_random (x);
- u = lrand48 ();
+ u = LONG_RAND ();
for (py=2; py<300; py++)
{
mpfr_set_prec (y, py);
@@ -150,33 +152,29 @@ check_nan (void)
int
main (int argc, char *argv[])
{
-#ifdef TEST
- {
- double x; unsigned long y, N; int i,rnd_mode,rnd;
-#ifdef __mips
- /* to get denormalized numbers on IRIX64 */
- union fpc_csr exp;
- exp.fc_word = get_fpc_csr();
- exp.fc_struct.flush = 0;
- set_fpc_csr(exp.fc_word);
-#endif
+#ifdef HAVE_FENV_H
+ double x;
+ unsigned long y, N;
+ int i, rnd_mode, rnd;
+
+ mpfr_test_init ();
- srand48(getpid());
+ SEED_RAND(time(NULL));
N = (argc<2) ? 1000000 : atoi(argv[1]);
rnd_mode = (argc<3) ? -1 : atoi(argv[2]);
- for (i=0;i<1000000;i++) {
- x = drand();
- y = lrand48();
- if (ABS(x)>4e-286) {
- /* avoid denormalized numbers and overflows */
- rnd = (rnd_mode==-1) ? lrand48()%4 : rnd_mode;
- check(y, x, rnd, 0.0);
+ for (i=0;i<1000000;i++)
+ {
+ x = drand();
+ y = LONG_RAND();
+ if (ABS(x)>4e-286)
+ {
+ /* avoid denormalized numbers and overflows */
+ rnd = (rnd_mode==-1) ? LONG_RAND()%4 : rnd_mode;
+ check(y, x, rnd, 0.0);
+ }
}
- }
- }
#endif
check_inexact ();
- check_nan ();
check(948002822, 1.22191250737771397120e+20, GMP_RNDN,
7.758352715731357946e-12);
check(1976245324, 1.25296395864546893357e+232, GMP_RNDZ,
diff --git a/mpfr/tests/tui_pow.c b/mpfr/tests/tui_pow.c
index 058c5b1c7..7505cc932 100644
--- a/mpfr/tests/tui_pow.c
+++ b/mpfr/tests/tui_pow.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_ui_pow.
-Copyright (C) 2001 Free Software Foundation.
+Copyright 2001 Free Software Foundation.
Adapted from tarctan.c.
This file is part of the MPFR Library.
@@ -16,7 +16,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/tests/tui_sub.c b/mpfr/tests/tui_sub.c
index c51a48207..2d34dc56d 100644
--- a/mpfr/tests/tui_sub.c
+++ b/mpfr/tests/tui_sub.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_ui_sub.
-Copyright (C) 2000-2001 Free Software Foundation.
+Copyright 2000, 2001, 2002 Free Software Foundation.
This file is part of the MPFR Library.
@@ -15,18 +15,18 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
+#include <time.h>
#include "gmp.h"
#include "mpfr.h"
-#ifdef TEST
+#include "mpfr-impl.h"
#include "mpfr-test.h"
-#endif
void special _PROTO ((void));
void check _PROTO ((unsigned long, double, mp_rnd_t, double));
@@ -140,11 +140,11 @@ check (unsigned long y, double x, mp_rnd_t rnd_mode, double z1)
mpfr_init2(zz, 53);
mpfr_set_d(xx, x, rnd_mode);
mpfr_ui_sub(zz, y, xx, rnd_mode);
-#ifdef TEST
+#ifdef HAVE_FENV_H
mpfr_set_machine_rnd_mode(rnd_mode);
#endif
if (z1==0.0) z1 = y-x;
- z2 = mpfr_get_d(zz);
+ z2 = mpfr_get_d1 (zz);
if (z1!=z2 && !(isnan(z1) && isnan(z2))) {
printf("expected difference is %1.20e, got %1.20e\n",z1,z2);
printf("mpfr_ui_sub failed for y=%lu x=%1.20e with rnd_mode=%s\n",
@@ -169,11 +169,11 @@ check_two_sum (mp_prec_t p)
mpfr_init2 (w, p);
do
{
- x = lrand48 ();
+ x = LONG_RAND ();
}
while (x < 1);
mpfr_random (y);
- rnd = rand() % 4;
+ rnd = LONG_RAND() % 4;
rnd = GMP_RNDN;
inexact = mpfr_ui_sub (u, x, y, GMP_RNDN);
mpfr_sub_ui (v, u, x, GMP_RNDN);
@@ -204,27 +204,22 @@ main (int argc, char *argv[])
{
mp_prec_t p;
unsigned k;
-#ifdef TEST
+#ifdef HAVE_FENV_H
double x;
unsigned long y, N;
int i, rnd_mode, rnd;
-#ifdef __mips
- /* to get denormalized numbers on IRIX64 */
- union fpc_csr exp;
- exp.fc_word = get_fpc_csr();
- exp.fc_struct.flush = 0;
- set_fpc_csr(exp.fc_word);
-#endif
- srand48(getpid());
+ mpfr_test_init ();
+
+ SEED_RAND (time(NULL));
N = (argc<2) ? 1000000 : atoi(argv[1]);
rnd_mode = (argc<3) ? -1 : atoi(argv[2]);
for (i=0;i<1000000;i++) {
- x = drand();
- y = lrand48();
+ x = drand ();
+ y = LONG_RAND ();
if (ABS(x)>2.2e-307) {
/* avoid denormalized numbers and overflows */
- rnd = (rnd_mode==-1) ? lrand48()%4 : rnd_mode;
+ rnd = (rnd_mode==-1) ? LONG_RAND()%4 : rnd_mode;
check(y, x, rnd, 0.0);
}
}
@@ -233,9 +228,11 @@ main (int argc, char *argv[])
for (p=2; p<100; p++)
for (k=0; k<100; k++)
check_two_sum (p);
- check(1, 1.0/0.0, GMP_RNDN, -1.0/0.0);
- check(1, -1.0/0.0, GMP_RNDN, 1.0/0.0);
- check(1, 0.0/0.0, GMP_RNDN, 0.0/0.0);
+#ifdef HAVE_INFS
+ check (1, DBL_POS_INF, GMP_RNDN, DBL_NEG_INF);
+ check (1, DBL_NEG_INF, GMP_RNDN, DBL_POS_INF);
+ check (1, DBL_NAN, GMP_RNDN, DBL_NAN);
+#endif
check(1196426492, 1.4218093058435347e-3, GMP_RNDN, 1.1964264919985781e9);
check(1092583421, -1.0880649218158844e9, GMP_RNDN, 2.1806483428158845901e9);
check(948002822, 1.22191250737771397120e+20, GMP_RNDN,
diff --git a/mpfr/ui_div.c b/mpfr/ui_div.c
index d55f98d6f..47803c56f 100644
--- a/mpfr/ui_div.c
+++ b/mpfr/ui_div.c
@@ -1,6 +1,6 @@
/* mpfr_ui_div -- divide a machine integer by a floating-point number
-Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+Copyright 2000, 2001 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/ui_pow.c b/mpfr/ui_pow.c
index a247166fe..ce573fdd2 100644
--- a/mpfr/ui_pow.c
+++ b/mpfr/ui_pow.c
@@ -1,6 +1,6 @@
/* mpfr_ui_pow -- power of n function n^x
-Copyright (C) 2001-2002 Free Software Foundation, Inc.
+Copyright 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/ui_pow_ui.c b/mpfr/ui_pow_ui.c
index 07f52472c..8c811a5cf 100644
--- a/mpfr/ui_pow_ui.c
+++ b/mpfr/ui_pow_ui.c
@@ -1,6 +1,6 @@
/* mpfr_ui_pow_ui -- compute the power beetween two machine integer
-Copyright (C) 1999-2002 Free Software Foundation, Inc.
+Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/ui_sub.c b/mpfr/ui_sub.c
index 65e96456c..77bc0d333 100644
--- a/mpfr/ui_sub.c
+++ b/mpfr/ui_sub.c
@@ -1,6 +1,6 @@
/* mpfr_ui_sub -- subtract a floating-point number from an integer
-Copyright (C) 2000-2002 Free Software Foundation, Inc.
+Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -15,7 +15,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
diff --git a/mpfr/urandomb.c b/mpfr/urandomb.c
index 0ffdf156f..4e7bb59a4 100644
--- a/mpfr/urandomb.c
+++ b/mpfr/urandomb.c
@@ -3,7 +3,7 @@
using STATE as the random state previously initialized by a call to
gmp_randinit().
-Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+Copyright 2000, 2001 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -18,7 +18,7 @@ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
-along with the MPFR Library; see the file COPYING.LIB. If not, write to
+along with the MPFR Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */