RealDocs

UKismetMathLibrary::Percent_IntInt

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

Description

Returns the remainder of integer division A % B. The sign of the result matches the sign of A (truncating modulo semantics).

Caveats & Gotchas

  • Modulo by zero (B=0) triggers a Blueprint runtime error and returns 0 in the engine's safe path; in raw C++ it is undefined behaviour.
  • Result sign follows the dividend (A), not the divisor: -7 % 3 = -1, not 2. If you need a non-negative remainder for array indexing or circular buffers, use `((A % B) + B) % B`.

Signature

static UE_INL_API int32 Percent_IntInt(int32 A, int32 B = 1);

Parameters

Name Type Description Default
A int32 Dividend.
B int32 Divisor (modulus). 1

Return Type

int32

Example

Non-negative wrap for circular buffer C++
// Safe circular index even for negative A:
int32 Wrapped = ((UKismetMathLibrary::Percent_IntInt(Index, BufferSize)) + BufferSize) % BufferSize;

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.