|
| 1 | +// IEEE 754 FMA special cases |
| 2 | +#include <assert.h> |
| 3 | +#include <math.h> |
| 4 | + |
| 5 | +int main() |
| 6 | +{ |
| 7 | + // fma(NaN, y, z) = NaN |
| 8 | + assert(isnan(fmaf(NAN, 1.0f, 0.0f))); |
| 9 | + |
| 10 | + // fma(x, NaN, z) = NaN |
| 11 | + assert(isnan(fmaf(1.0f, NAN, 0.0f))); |
| 12 | + |
| 13 | + // fma(x, y, NaN) = NaN |
| 14 | + assert(isnan(fmaf(1.0f, 1.0f, NAN))); |
| 15 | + |
| 16 | + // fma(0, inf, z) = NaN (0 * inf is undefined) |
| 17 | + assert(isnan(fmaf(0.0f, INFINITY, 1.0f))); |
| 18 | + |
| 19 | + // fma(inf, 0, z) = NaN |
| 20 | + assert(isnan(fmaf(INFINITY, 0.0f, 1.0f))); |
| 21 | + |
| 22 | + // fma(inf, x, -inf) = NaN when inf*x = +inf (inf + (-inf) is undefined) |
| 23 | + assert(isnan(fmaf(INFINITY, 1.0f, -INFINITY))); |
| 24 | + |
| 25 | + // fma(inf, x, z) = +inf for finite z |
| 26 | + assert(isinf(fmaf(INFINITY, 2.0f, 3.0f))); |
| 27 | + |
| 28 | + // fma(x, y, inf) = +inf for finite x*y |
| 29 | + assert(isinf(fmaf(2.0f, 3.0f, INFINITY))); |
| 30 | + |
| 31 | + return 0; |
| 32 | +} |
0 commit comments