RealDocs

UKismetMathLibrary::SignOfInteger64

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

Description

Returns -1 if A is negative, 0 if A is zero, and +1 if A is positive. Useful for extracting the direction of a signed quantity without a branch.

Caveats & Gotchas

  • Returns 0 for exactly zero, which distinguishes it from a simple < 0 check. If your code treats zero as positive (e.g. for array indexing), explicitly check for zero before using the result as a multiplier.
  • The return type is int64 but the value is always -1, 0, or 1 — it is safe to cast to int32 or use directly in arithmetic without overflow risk.

Signature

static UE_INL_API int64 SignOfInteger64(int64 A);

Parameters

Name Type Description Default
A int64 The value whose sign to query.

Return Type

int64

Example

Apply sign to a capped magnitude C++
int64 Delta = GetDelta(); // may be negative
int64 Magnitude = FMath::Abs(Delta);
int64 Sign = UKismetMathLibrary::SignOfInteger64(Delta);
int64 SteppedDelta = Sign * FMath::Min(Magnitude, MaxStep);

Tags

Version History

Introduced in: unknown

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.