I'm having some issues with my game and it's numbers.
I want to create a balance that has 4 decimals. So my number start with 0.0000.
As 1.0000 stands for "1" and 12.3000 stands for "12.3".
At this moment i use round(N * 10000) / 10000 to show my numbers like 0.001 but i can't fix the fourth 0.
Also some of my objects have the price of 0.0001 which will not be possible. I can set a instance variable up to 3 decimals. So 0.001 is possible but 0.0001 is not.
My exact goal is:
Start out with 0.0001
Able to display 1.0000 as 1.0000
Able to display 10.0000 as 10.0000
Able to display 100.0000 as 100.0000
Able to display 1000.0000 as 1K
Able to display 1200.0000 as 1.2K
Able to display 10000.0000 as 10K
Able to display 12000.0000 as 12K
Able to display 100000.0000 as 100K
Able to display 120000.0000 as 120K
Able to display 1000000.0000 as 1M
Able to display 1200000.0000 as 12M
Any one here able to help me into the right direction?
Develop games in your browser. Powerful, performant & highly capable.
This will format the number as "1.0000"
Set decimal to round((number-int(number))*10000)
Set text "txtNumber" to -> int(number) & "." & zeropad(decimal,4)
Thanks for your reply!
This works perfect and i want to use this from 0.0001 till 999.9999 But after that i want to start using "K" as thousand, "M" as million, "B" as billion etc.
This means that in the K is should change from xxx.xxxx to 1.001K
Any idea what the math on that one is? All it has to do actually is move the dot 3 times to the left.
Thanks in advance!
You can do something like this:
If N>=1000 then Set Text to (round(N* 10) / 10000) & "K"