Rate This Document
Findability
Accuracy
Completeness
Readability

fmin

Return the minimum value of the input parameters.

Interface Definition

C interface:

float fmaxf(float x, float y);

double fmax(double x, double y);

Parameters

Parameter

Type

Description

Input/Output

x

  • For fminf, x is of single-precision floating-point type.
  • For fmin, x is of double-precision floating-point type.

Floating-point value of the input data.

Input

y

  • For fminf, y is of single-precision floating-point type.
  • For fmin, y is of double-precision floating-point type.

Floating-point value of the input data.

Input

Return Value

  • The smaller value between x and y is returned.
  • For special values, see the following table.

Input Value (x)

Input Value (y)

Return Value

any

qnan

x

qnan

any

y

any

snan

nan

snan

any

nan

Dependency

C: "km.h"

Example

C interface:
    // typical usage
    double x1 = 0.0, x2 = -0.0, x3 = 1.4, x4 = -2.7;
    double y1 = -0.0, y2 = 0.0, y3 = 1.5, y4 = -2.1;
    // special handing
    double a = INFINITY, b = -INFINITY, c = NAN;
    printf("fmin(0.0, -0.0) = %.15f\n", fmin(x1, y1));
    printf("fmin(-0.0, 0.0) = %.15f\n", fmin(x2, y2));
    printf("fmin(1.4, 1.5) = %.15f\n", fmin(x3, y3));
    printf("fmin(-2.7, -2.1) = %.15f\n", fmin(x4, y4));
    printf("fmin(INFINITY, 1.4) = %.15f\n", fmin(a, x3));
    printf("fmin(-INFINITY, -2.7) = %.15f\n", fmin(b, x4));
    printf("fmin(NAN, 1.4) = %.15f\n", fmin(c, x3));
    printf("fmin(NAN, INFINITY) = %.15f\n", fmin(c, a));
    printf("fmin(NAN, -INFINITY) = %.15f\n", fmin(c, b));
    printf("fmin(INFINITY, -INFINITY) = %.15f\n", fmin(a, b));
    /* 
     *fmin(0.0, -0.0) = -0.000000000000000
     *fmin(-0.0, 0.0) = -0.000000000000000
     *fmin(1.4, 1.5) = 1.400000000000000
     *fmin(-2.7, -2.1) = -2.700000000000000
     *fmin(INFINITY, 1.4) = 1.400000000000000
     *fmin(-INFINITY, -2.7) = -inf
     *fmin(NAN, 1.4) = 1.400000000000000
     *fmin(NAN, INFINITY) = inf
     *fmin(NAN, -INFINITY) = -inf
     *fmin(INFINITY, -INFINITY) = -inf
     * */