RealDocs

UKismetMathLibrary::Conv_IntToByte

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

Description

Narrows a 32-bit integer to a uint8 byte by taking the low 8 bits. Negative integers and values above 255 silently wrap — always validate input range before calling if correctness matters.

Caveats & Gotchas

  • The conversion is a bitwise truncation, not a clamp. Passing 256 returns 0, passing 257 returns 1, passing -1 returns 255. If you need clamping, use FMath::Clamp(InInt, 0, 255) first.
  • Blueprint's autocast uses this function when an Integer pin drives a Byte input. This silent truncation has caused subtle bugs where designers pass values like 300 (meant as a large health number) and get unexpected results.

Signature

static UE_INL_API uint8 Conv_IntToByte(int32 InInt);

Parameters

Name Type Description Default
InInt int32 The integer to narrow. Values outside 0–255 return the low 8 bits.

Return Type

uint8

Example

Pack a 0-100 percentage into a byte safely C++
int32 Percent = FMath::Clamp(RawPercent, 0, 100);
uint8 PackedPercent = UKismetMathLibrary::Conv_IntToByte(Percent);

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.