nn::math::Clamp Function

Syntax

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

Template Arguments

Name Description
T Type representing a numeric value

Arguments

Name Description
in x Target value
in low Lower threshold
in high Higher threshold

Return Values

if x is in [low, high], then x is returned. If it is outside this range, then either low or high is returned.

Description

Fits a value within the specified range.

If x is not within low and high, then either low or high is returned (whichever is closest to the value).

Revision History

2011/03/01
Initial version.

CONFIDENTIAL