fdim
Return zero if x is smaller than or equal to y, or return a value of x - y if x is greater than y.
Interface Definition
C interface:
float fdimf(float x, float y);
double fdim(double x, double y);
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
x |
|
Floating-point value of the input data. |
Input |
y |
|
Floating-point value of the input data. |
Input |
Return Value
- errno: If the return value is inf, it is set to ERANGE.
- If x < y, the return value is 0.
- If x ≥ y, the return value is x – y.
- If x or y is NaN, the return value is NaN.
Dependencies
C: "km.h"
Examples
C interface:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | // typical usage printf("fdim(1.0, 2.0) = %.15f\n", fdim(1.0, 2.0)); printf("fdim(3.0, 2.0) = %.15f\n", fdim(3.0, 2.0)); // special handling printf("fdim(INFINITY, INFINITY) = %.15f\n", fdim(INFINITY, INFINITY)); printf("fdim(INFINITY, -INFINITY) = %.15f\n", fdim(INFINITY, -INFINITY)); printf("fdim(-INFINITY, INFINITY) = %.15f\n", fdim(-INFINITY, INFINITY)); printf("fdim(-INFINITY, -INFINITY) = %.15f\n", fdim(-INFINITY, -INFINITY)); printf("fdim(NAN, -INFINITY) = %.15f\n", fdim(NAN, -INFINITY)); result /* * fdim(1.0, 2.0) = 0.000000000000000 * fdim(3.0, 2.0) = 1.000000000000000 * fdim(INFINITY, INFINITY) = 0.000000000000000 * fdim(INFINITY, -INFINITY) = inf * fdim(-INFINITY, INFINITY) = 0.000000000000000 * fdim(-INFINITY, -INFINITY) = 0.000000000000000 * fdim(NAN, -INFINITY) = nan * */ |
Parent topic: Miscellaneous Functions