How to check the amount of decimal places in a float?

I’m using an array of floats in my game to represent money, if there is only 1 decimal place in a float I want to add a zero, how would I do this? For example, £1100.7 should look like £1100.70.

Maybe this will work for you. When you convert a float to text…

226308-capture.png

…you get to decide how many fractional digits to keep. In your case, you’d set the min/max to 2.

Thanks very much

Forgot this thing existed; it was deprecated some time ago. It used to mess up the currency code being on the left/right of the value. If it is working as intended now, this is an elegant solution when working with bulk data.

You could use the AsCurrency function

It uses Integer values so in your case it would be the integer number 110070 with the Currency code
GBP You can find all the currency codes in ISO 4217 if you need others.

The old AsCurrency(int) and AsCurrency(float) are deprecated yes. But the simple version where you can only input an Integer and a Currency code should work as expected.

You can return how many decimal places a float has like this and then add some logic based on the number. Copy-paste this function into your blueprint library. :wink:

Return How Many Decimal Places Input Float Has posted by anonymous | blueprintUE | PasteBin For Unreal Engine