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

**URL:** <https://forums.unrealengine.com/t/how-to-check-the-amount-of-decimal-places-in-a-float/414003>\
**Category:** Community & Industry Discussion\
**Tags:** money, float, unreal-engine, Array, UE4, Blueprint, question\
**Created:** [January 7, 2018, 8:04pm UTC](https://forums.unrealengine.com/t/how-to-check-the-amount-of-decimal-places-in-a-float/414003 "2018-01-07T20:04:04Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheRealObamaMan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TheRealObamaMan](https://forums.unrealengine.com/u/TheRealObamaMan)\
**Post date:** [January 7, 2018, 8:04pm UTC](https://forums.unrealengine.com/t/how-to-check-the-amount-of-decimal-places-in-a-float/414003/1 "2018-01-07T20:04:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [January 7, 2018, 8:52pm UTC](https://forums.unrealengine.com/t/how-to-check-the-amount-of-decimal-places-in-a-float/414003/2 "2018-01-07T20:52:05Z")

</div>

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

![226308-capture.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/1/6/c164591546d8c520846726466cde68cca48bb6d7.png)

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

---

<div class="post-metadata">

**Author:** ![TheRealObamaMan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TheRealObamaMan](https://forums.unrealengine.com/u/TheRealObamaMan)\
**Post date:** [January 7, 2018, 9:50pm UTC](https://forums.unrealengine.com/t/how-to-check-the-amount-of-decimal-places-in-a-float/414003/3 "2018-01-07T21:50:30Z")

</div>

Thanks very much

---

<div class="post-metadata">

**Author:** ![GarnerP57](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GarnerP57](https://forums.unrealengine.com/u/GarnerP57)\
**Post date:** [January 7, 2018, 10:02pm UTC](https://forums.unrealengine.com/t/how-to-check-the-amount-of-decimal-places-in-a-float/414003/4 "2018-01-07T22:02:29Z")

</div>

You could use the [AsCurrency](https://docs.unrealengine.com/latest/INT/BlueprintAPI/Utilities/Text/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.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [January 7, 2018, 10:13pm UTC](https://forums.unrealengine.com/t/how-to-check-the-amount-of-decimal-places-in-a-float/414003/5 "2018-01-07T22:13:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![GarnerP57](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GarnerP57](https://forums.unrealengine.com/u/GarnerP57)\
**Post date:** [January 7, 2018, 10:19pm UTC](https://forums.unrealengine.com/t/how-to-check-the-amount-of-decimal-places-in-a-float/414003/6 "2018-01-07T22:19:12Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![VelikyPanda](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/velikypanda/32/1008648_2.png) [@VelikyPanda](https://forums.unrealengine.com/u/VelikyPanda)\
**Post date:** [October 22, 2023, 2:36pm UTC](https://forums.unrealengine.com/t/how-to-check-the-amount-of-decimal-places-in-a-float/414003/7 "2023-10-22T14:36:42Z")

</div>

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. 😉

[Return How Many Decimal Places Input Float Has posted by anonymous | blueprintUE | PasteBin For Unreal Engine](https://blueprintue.com/blueprint/qrnt3uzw/)
