nn::math::Clamp Function

Syntax

template <typename T>
T Clamp(
     T x,
     T low,
     T high
);

Template Arguments

Name Description
T Type representing a numerical value.

Parameters

Name Description
in x Value to operate on.
in low Low threshold value.
in high High threshold value.

Return Values

If x is in the [low, high] range, this function returns x; if x is outside the range, this function returns either low or high.

Description

Clamps a value to the specified range.

If x is not between low and high, this function returns the value (either low or high) that is closer to x.

Revision History

2011/03/01
Initial version.

CONFIDENTIAL