Go to the first, previous, next, last section, table of contents.


Floating-point Functions

This is a description of the preliminary interface for floating-point arithmetic in GNU MP 2.

The floating-point functions expect arguments of type mpf_t.

The MP floating-point functions have an interface that is similar to the MP integer functions. The function prefix for floating-point operations is mpf_.

There is one significant characteristic of floating-point numbers that has motivated a difference between this function class and other MP function classes: the inherent inexactness of floating point arithmetic. The user has to specify the precision of each variable. A computation that assigns a variable will take place with the precision of the assigned variable; the precision of variables used as input is ignored.

The precision of a calculation is defined as follows: Compute the requested operation exactly (with "infinite precision"), and truncate the result to the destination variable precision. Even if the user has asked for a very high precision, MP will not calculate with superfluous digits. For example, if two low-precision numbers of nearly equal magnitude are added, the precision of the result will be limited to what is required to represent the result accurately.

The MP floating-point functions are not intended as a smooth extension to the IEEE P754 arithmetic. Specifically, the results obtained on one computer often differs from the results obtained on a computer with a different word size.


Go to the first, previous, next, last section, table of contents.