RealDocs

UKismetMathLibrary::InRange_FloatFloat

function Engine Blueprint Since 4.0
#include "Kismet/KismetMathLibrary.h"
Access: public Specifiers: staticUFUNCTIONBlueprintPure

Description

Returns true if Value is within the range [Min, Max]. Boundary inclusivity can be toggled independently for min and max.

Caveats & Gotchas

  • • Boundary checks use exact floating-point comparison — if Value was computed and theoretically equals Min or Max, rounding errors may make it narrowly outside the range. Consider widening Min/Max by a small epsilon when testing computed boundary values.
  • • Does not validate that Min <= Max — if Min > Max the function returns false for all values, silently, with no error or assertion.

Signature

static ENGINE_API bool InRange_FloatFloat(double Value, double Min, double Max, bool InclusiveMin = true, bool InclusiveMax = true);

Parameters

Name Type Description Default
Value double The value to test. —
Min double The lower bound of the range. —
Max double The upper bound of the range. —
InclusiveMin bool If true, Value == Min passes (>= check); if false, strictly greater than (> check). true
InclusiveMax bool If true, Value == Max passes (<= check); if false, strictly less than (< check). true

Return Type

bool

Example

Validate a normalised alpha value C++
double Alpha = ComputeBlend();
if (!UKismetMathLibrary::InRange_FloatFloat(Alpha, 0.0, 1.0))
{
    UE_LOG(LogTemp, Warning, TEXT("Alpha out of range: %f"), Alpha);
    Alpha = FMath::Clamp(Alpha, 0.0, 1.0);
}

Tags

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable —

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.