Unreal Engine 5 · Blueprint → C++
Modulo in Unreal Engine 5 C++UE Docs
The Modulo Blueprint node maps to the % operator for integers (A % B) and FMath::Fmod(A, B) for floats in Unreal Engine 5 C++.
Blueprint node & C++ equivalent
int32 IntMod = A % B;
float FloatMod = FMath::Fmod(A, B);What does the Modulo node do?
Modulo returns the remainder after dividing one number by another. It is the standard tool for wrapping values, cycling through arrays, and creating repeating patterns such as ping-pong indices or grid coordinates.
Blueprint exposes both integer and float variants, and the C++ equivalents differ accordingly.
The C++ equivalent
For integers, use the native % operator: int32 IntMod = A % B. For floating-point values, the % operator does not apply, so call FMath::Fmod(A, B) to get the float remainder.
Both follow C++ truncated-division semantics, so the sign of the result matches the dividend A, not the divisor B.
Common mistakes
A modulo by zero with the % operator is undefined behavior and can crash, so guard B against zero. Be aware that negative dividends produce negative remainders; if you need a result that is always positive, add B and take the modulo again.
Frequently asked questions
How do you do modulo on a float in UE5 C++?+
The % operator only works on integers. For floats, use FMath::Fmod(A, B), which returns the floating-point remainder of A divided by B.
Why is my modulo result negative in Unreal C++?+
C++ modulo follows the sign of the dividend. If A is negative the remainder is negative. Add B and take the modulo again to force a positive result.