UKismetMathLibrary::Divide_Int64Int64
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticBlueprintPure
Description
Divides two 64-bit integers using integer (truncating) division (A / B). Division by zero is reported via ReportError_Divide_Int64Int64 and returns 0.
Caveats & Gotchas
- • Division is truncated toward zero, not floored. -7 / 2 returns -3, not -4. If you need floor division for negative numbers, handle the sign manually.
- • Dividing by zero does not crash — UE calls ReportError_Divide_Int64Int64 which logs an error and returns 0. However, silently returning 0 can cascade into incorrect game logic. Validate B != 0 before calling in production code.
Signature
static UE_INL_API int64 Divide_Int64Int64(int64 A, int64 B = 1); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| A | int64 | Dividend. | — |
| B | int64 | Divisor. Defaults to 1. | 1 |
Return Type
int64 Example
Convert bytes to megabytes C++
int64 MB = UKismetMathLibrary::Divide_Int64Int64(TotalBytes, 1024LL * 1024LL); Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?