UKismetMathLibrary::FTrunc
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticBlueprintPureUFUNCTION
Description
Rounds A towards zero by dropping the fractional part. -1.6 becomes -1 and 1.6 becomes 1. Differs from FFloor for negative numbers.
Caveats & Gotchas
- • Truncation and flooring differ for negative numbers: FTrunc(-1.6) == -1 but FFloor(-1.6) == -2. Choose based on whether you want magnitude-reduction or always-down behavior.
- • Tagged BlueprintAutocast so UE will automatically insert this conversion when a float pin is connected to an int32 pin in Blueprint. Implicit truncation can cause unexpected off-by-one results.
Signature
static UE_INL_API int32 FTrunc(double A); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| A | double | The floating-point value to truncate. | — |
Return Type
int32 Example
Convert a fractional timer to whole seconds C++
float ElapsedTime = 4.99f;
int32 WholeSeconds = UKismetMathLibrary::FTrunc(ElapsedTime); // returns 4 Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?