UKismetMathLibrary::Abs_Int
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticBlueprintPure
Description
Returns the absolute (non-negative) value of A. Equivalent to FMath::Abs for int32.
Caveats & Gotchas
- • Abs_Int(INT_MIN) (-2147483648) is undefined behaviour in C++ because the mathematical absolute value (2147483648) cannot be represented in int32. The result is implementation-defined and will typically overflow back to INT_MIN. Guard against this if your input can be the minimum integer.
- • For floats use Abs (the float overload) or FMath::Abs. There is no Blueprint absolute-value node that accepts int64; cast to float first if needed.
Signature
static UE_INL_API int32 Abs_Int(int32 A); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| A | int32 | The integer whose absolute value is returned. | — |
Return Type
int32 Example
Compute Manhattan distance on a grid C++
int32 ManhattanDist = UKismetMathLibrary::Abs_Int(TargetX - OriginX)
+ UKismetMathLibrary::Abs_Int(TargetY - OriginY); Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?