Download

Are there any Custom Integer Bit Sizes in UE4 C++ Such as 3-bit, 4-bit, 5-bit etc.

Good day,

I’m trying to generate data (like a lot of it) out of an array of integer values and I’m trying to save as much memory as I could. Its max values are just of an unsigned nibble which is 15. Been searching if i can make a nibble (the 4-bit sized data) out of integer. Does unreal have such thing? Maybe I’m just bad at google searches but yes haven’t found any answer yet. Btw just starting on c++ UE4. Thanks!

Sounds like you’re looking for this: Bit field - cppreference.com
Not entirely certain how well this is supported in combination with UPROPERTY though. I’m unaware of any places where it’s an actual 2-bit or more integer but some UE4 classes like AActor or APlayerController use this for multiple boolean type UPROPERTY flags.
In the worst case you can wrap two of your 4-bit values in a 1-byte USTRUCT with this and create a function library with appropriate helper functions.