UKismetMathLibrary::Divide_IntInt
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintPure
Description
Divides integer A by integer B and returns the truncated quotient. The default B=1 is a safety net, not a useful value in practice.
Caveats & Gotchas
- • Division by zero (B=0) triggers a Blueprint runtime error and returns 0; in C++ it is undefined behaviour. Always guard B.
- • Truncation is toward zero, not toward negative infinity: -7 / 2 = -3, not -4. This differs from Python's floor division and can surprise developers coming from that language.
Signature
static UE_INL_API int32 Divide_IntInt(int32 A, int32 B = 1); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| A | int32 | Dividend. | — |
| B | int32 | Divisor. | 1 |
Return Type
int32 Example
Integer halving C++
int32 HalfScore = UKismetMathLibrary::Divide_IntInt(TotalScore, 2);
// -7 / 2 == -3, not -4 Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?