Mathematical constants, some convenient functions wrappers and
type traits to support arbitrary-precision arithmetic.
|
Bit manipulations for testing whether an integer is a power of two, for
computing the exponent of an integer that is a power of two, for
determining the leading and trailing 1-valued bits of an integer, and
for rounding an integer up or down to a power of two.
|
A template class IEEEBinary encapsules some information about
floating-point numbers in the IEEE 754-2008 Standard for Floating-Point
Arithmetic. IEEEBinary32 and IEEEBinary64 are explicitly instantiated.
IEEEBinary16 is an implementation of 16-bit floating-point arithmetic.
|
In the acronyms for the files and classes, BS stands for "binary scientific".
The template type UIntegerType is either UIntegerAP32 for
arbitrary precision arithmetic using std::vector storage or
UIntegerFP32<N> for user-selected fixed-precision arithmetic
using std::array storage. BSNumber (Binary Scientific Number) is an
implementation of arbitrary precision floating-point arithmetic that supports
addition, subtraction, and multiplication. If you have an algorithm that requires
division, use BSRational. The QFNumber class encapsulates quadratic-field
arithmetic. The APConversion class encapsulates several estimation functions
for quadratic-field numbers and conversions from arbitrary-precision numbers
to floating-point numbers. Much of this code is expanded in the Geometric
Tools Library that will ship in the first half of 2020. It is based on my
forthcoming book Robust and Error-Free Geometric Computing.
|
Support for interval arithmetic. The FPInterval file uses std::fesetround and
std::fegetround (found in <cfenv>) to change the rounding mode
of the floating-point hardware. Unfortunately, GCC does not support this
via C++ (you can do it with assembly instructions). Microsoft Visual Studio
support this, but with a pragma that is not part of the C++ specifications.
Moreover, the pragmas must occur at file scope (not function-block scope).
These issues are problematic when trying to provide template classes with
template parameters float or double in stand-alone header
files. Instead, consider using the SWInterval file that relies on
std::nextafter and produces slightly larger intervals. The APInterval file
provides interval arithmetic for arbitrary-precision numbers.
|
Jonathan Richard Shewchuk's web page with a link to his paper on
adaptive precision floating-point arithmetic and fast robust
geometric predicates. Links are also provided to source code
and related resources.
|