• News

• Industries

• Learning & Support

• Community

• Marketplace

# Integer vs Float: Relict of old days or a real thing?

Is there some cases where it’s better to use Integer values instead of *Float *values? Of course in terms of blueprint gamedev.
Back in the days it was a noticeable performance difference. But with today’s powerful computers, does it really matter when it comes to basic game logic calculation, like strength of an attack or ammo count?
When I know that some variable would never need a floating point value, then I set it to Integer. But I’m curious what would happen after totally ignoring Integer values and using Float for every numeric value - if it really would matter at all

Floating point precision error is a great reason in my opinion, lets say I have a value that represents the number of players, and it is a float. If my value was 10, and I multiplied it by a large whole number, it would not longer be a whole number because of floating point precision. Another reason is that you’d need to be constantly converting between floats and ints, and it would become very tedious very fast.

That makes sense! So you say that, for example, float value 10 after multiplying by **10000 **can become like ~100000.01?

This guy has a great explanation of what Jamen mentioned https://youtu.be/PZRI1IfStY0

Plus it makes for good clarity when you know a certain variable only represents an integer.

Just watched it, fantastic explanation.

Good video. Definitely a better idea to use integers when you know you want the number as a single digit since you know for sure its either going to be 1 or 2 not 1.4 or 1.5 and require rounding.

Great video…

My mind = blown from that easy explanation.

Also consider the memory management implications .

in a small app or game this wouldn’t really matter. But in a app/program with thousands of variables If you use the wrong type to store data it can cause a lot of memory leaks, lag and problems later on etc.

It all depends on how big of a number or how much data/ information you need to store. If you look online there are loads of tables that show you each variable and how much memory they have etc and what values get can hold.