1228
1228
where @math{p} is the number of bits in the mantissa of the
1229
1229
floating-point number representation. Ideally the error for all
1230
functions is always less than 0.5ulps. Using rounding bits this is also
1231
possible and normally implemented for the basic operations. To achieve
1232
the same for the complex math functions requires a lot more work and
1233
this has not yet been done.
1230
functions is always less than 0.5ulps in round-to-nearest mode. Using
1231
rounding bits this is also
1232
possible and normally implemented for the basic operations. Except
1233
for certain functions such as @code{sqrt}, @code{fma} and @code{rint}
1234
whose results are fully specified by reference to corresponding IEEE
1235
754 floating-point operations, and conversions between strings and
1236
floating point, @theglibc{} does not aim for correctly rounded results
1237
for functions in the math library, and does not aim for correctness in
1238
whether ``inexact'' exceptions are raised. Instead, the goals for
1239
accuracy of functions without fully specified results are as follows;
1240
some functions have bugs meaning they do not meet these goals in all
1241
cases. In future, @theglibc{} may provide some other correctly
1242
rounding functions under the names such as @code{crsin} proposed for
1243
an extension to ISO C.
1248
Each function with a floating-point result behaves as if it computes
1249
an infinite-precision result that is within a few ulp (in both real
1250
and complex parts, for functions with complex results) of the
1251
mathematically correct value of the function (interpreted together
1252
with ISO C or POSIX semantics for the function in question) at the
1253
exact value passed as the input. Exceptions are raised appropriately
1254
for this value and in accordance with IEEE 754 / ISO C / POSIX
1255
semantics, and it is then rounded according to the current rounding
1256
direction to the result that is returned to the user. @code{errno}
1257
may also be set (@pxref{Math Error Reporting}).
1260
For the IBM @code{long double} format, as used on PowerPC GNU/Linux,
1261
the accuracy goal is weaker for input values not exactly representable
1262
in 106 bits of precision; it is as if the input value is some value
1263
within 0.5ulp of the value actually passed, where ``ulp'' is
1264
interpreted in terms of a fixed-precision 106-bit mantissa, but not
1265
necessarily the exact value actually passed with discontiguous
1269
Functions behave as if the infinite-precision result computed is zero,
1270
infinity or NaN if and only if that is the mathematically correct
1271
infinite-precision result. They behave as if the infinite-precision
1272
result computed always has the same sign as the mathematically correct
1276
If the mathematical result is more than a few ulp above the overflow
1277
threshold for the current rounding direction, the value returned is
1278
the appropriate overflow value for the current rounding direction,
1279
with the overflow exception raised.
1282
If the mathematical result has magnitude well below half the least
1283
subnormal magnitude, the returned value is either zero or the least
1284
subnormal (in each case, with the correct sign), according to the
1285
current rounding direction and with the underflow exception raised.
1288
Where the mathematical result underflows and is not exactly
1289
representable as a floating-point value, the underflow exception is
1290
raised (so there may be spurious underflow exceptions in cases where
1291
the underflowing result is exact, but not missing underflow exceptions
1292
in cases where it is inexact).
1295
@Theglibc{} does not aim for functions to satisfy other properties of
1296
the underlying mathematical function, such as monotonicity, where not
1297
implied by the above goals.
1300
All the above applies to both real and complex parts, for complex
1235
1305
Therefore many of the functions in the math library have errors. The
1236
1306
table lists the maximum error for each function which is exposed by one