any of the two ways are ok this one to
float FloatNumb = 35.234;
int32 IntNumb = (int32)FloatNumb;
but the cast will always “floor” the float value, it can be 1,99 after the cast it will become 1 not 2 so. But as long as you don’t mind everything is fine
I’m relatively new to Unreal and C++, so can somebody help me.
How do i get this conversion?
float FloatNumb = 35.234;
int32 IntNumb = static_cast<int32>(FloatNumb);
or just simply:
float FloatNumb = 35.234;
int32 IntNumb = FloatNumb;
I get same results for both, but i need the right way
1 Like
iSpakkio
(iSpakkio)
May 19, 2016, 7:38pm
3
I Don’t think it does really matter which way you convert them,but i think the second option is cleaner than the first
zimzimdz
(zimzimdz)
May 19, 2016, 7:41pm
4
int32 IntNumb = FMath::FloorToInt(FloatNumb);
1 Like
Btw. in plain c++ int32 value = float value will generate warning about conversion and possible data lost so you have to cast explicitly to avoid it