Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / [SOLVED] Display 2 placed fixed decimal, displaying money amount

Author
Message
PeteyM5
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Buffalo NY USA
Posted: 24th Jul 2020 22:13
For games that you play for money or use money in the game, some of us my need to display the amount for two fixed decimal places. I could not find the specific function the the APK help documents. I wrote this short routine that seems to work.

Function MoneyStr(Money_In as Float)
Local NewStr as String
Local I as Integer
NewStr = STR(Money_In)
I = FindString(NewStr,".")
If I = 0
NewStr = NewStr + ".00"
Else
NewStr = NewStr + "00"
NewStr = Left(NewStr,I+3)
Endif
Endfunction NewStr

The author of this post has marked a post as an answer.

Go to answer

Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 24th Jul 2020 23:02
This post has been marked by the post author as the answer.
Just so you know, the str() function does that for you:
https://www.appgamekit.com/documentation/Reference/Core/Str.htm

So print(str(4.8264762 , 2)) prints 4.82

Login to post a reply

Server time is: 2024-03-28 09:04:09
Your offset time is: 2024-03-28 09:04:09