x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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.

Product Version: UE 4.18
Tags:
more ▼

asked Jan 07 '18 at 08:04 PM in Blueprint Scripting

avatar image

TheRealObamaMan
3 1 2 3

(comments are locked)
10|2000 characters needed characters left

2 answers: sort voted first

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

alt text

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

capture.png (26.7 kB)
more ▼

answered Jan 07 '18 at 08:52 PM

avatar image

Everynone
12.6k 72 24 53

avatar image TheRealObamaMan Jan 07 '18 at 09:50 PM

Thanks very much

(comments are locked)
10|2000 characters needed characters left

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.

more ▼

answered Jan 07 '18 at 10:02 PM

avatar image

GarnerP57
691 3 4 6

avatar image Everynone Jan 07 '18 at 10:13 PM

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.

avatar image GarnerP57 Jan 07 '18 at 10:19 PM

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.

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question