UKismetMathLibrary::ClampInt64
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintPure
Description
Returns Value clamped to the range [Min, Max], inclusive on both ends. Equivalent to MaxInt64(Min, MinInt64(Value, Max)).
Caveats & Gotchas
- • If Min > Max, the result is implementation-defined (usually Max, since MinInt64 runs first). Always ensure Min <= Max; consider asserting in debug builds when the bounds come from runtime data.
- • Clamping does not protect against overflow in the value itself — if Value has already wrapped around due to integer overflow, clamping to a sane range will not recover the intended value.
Signature
static UE_INL_API int64 ClampInt64(int64 Value, int64 Min, int64 Max); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| Value | int64 | The value to clamp. | — |
| Min | int64 | Inclusive lower bound. | — |
| Max | int64 | Inclusive upper bound. | — |
Return Type
int64 Example
Clamp a player reputation score C++
const int64 MinRep = -100000LL;
const int64 MaxRep = 100000LL;
ReputationScore = UKismetMathLibrary::ClampInt64(ReputationScore, MinRep, MaxRep); See Also
Tags
Version History
Introduced in: unknown
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?