# How do I show and calculate my numbers correctly

0 favourites
• 4 posts
From the Asset Store
The ultimate voice pack filled with 1,536 files of .......wav and mp3 of individual numbers, letters, and words (that go
• Hi guys,

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

ETC.

Any one here able to help me into the right direction?

• ## Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• This will format the number as "1.0000"

variable decimal=0
Set decimal to round((number-int(number))*10000)
Set text "txtNumber" to -> int(number) & "." & zeropad(decimal,4)
[/code:1lytxge9]

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.