# How do I removed the decimal point and the decimals

Get help using Construct 2

### » Fri Feb 06, 2015 1:30 am

hey guys hey guys i really need to solve this problem i have,

im doing a timemanagement game, that has a bunch of texts and prices and 1 multiple that increases the prices with each purchase so :

here is my coding of the text

Set Text to : " \$ "&item1.price&newline&"Income : \$ " & item1.income&" x "&item1count

the problem is this :
when i do a new purchase of the item1 the item1.price its multiplyed by 1.20 so every 3 purchases i get a trail of digits.
i woldnt mind 1 digit (ex:N.N) but i have prices higher then the item1price (wich is 50) and they are in billions and millions and so on , so the decimals at that point will be insane the problem is i need to take even the . out without showing decimals, i need 103.75 to be shown as 103 and thats it any help?!

was hoping @fisholith can help me or someone that knows this problem
B
86
S
26
G
75
Posts: 1,439
Reputation: 47,803

### » Fri Feb 06, 2015 1:33 am

Try this: Set Text to : " \$ "&round(item1.price)&newline&"Income : \$ " & round(item1.income)&" x "&item1count
B
11
S
4
G
2
Posts: 116
Reputation: 1,936

### » Fri Feb 06, 2015 1:36 am

But of course it whould be better to use the round-function on the actuall variable instead.
B
11
S
4
G
2
Posts: 116
Reputation: 1,936

### » Fri Feb 06, 2015 1:46 am

Your awesome solved my issue @DetteMan
B
86
S
26
G
75
Posts: 1,439
Reputation: 47,803

### » Fri Feb 06, 2015 1:49 am

B
11
S
4
G
2
Posts: 116
Reputation: 1,936

### » Sun Feb 08, 2015 1:17 pm

you did helped me but dident tested till now further, .... i used floor , and works great for numbers under 10,000 but once i do more then 10,000 i tested it with millions and thousands so far , on under 1000 works good even with floor and also with Round, but when i get higher numbers
as 1mil and . 212313 (exactly 6 decimals so im guessing when im gonna have billions the decimals will be 9
so above 10,000 with round the decimals are still there, but if i use floor the same number as with round but without a dot between the first high number e.g. 2.123123 mil 25.123123mil someone knows this? i tried with floor(round(number)) but it only applyes as it is only floor
is there anything as a command to or simple event line that tells to show only what is before the .?
@DetteMan
B
86
S
26
G
75
Posts: 1,439
Reputation: 47,803

### » Sun Feb 08, 2015 3:04 pm

nevermind i found 1 solution its kinda not complete and involves alot of event lines and variables. so hard..... why isnt there a system that does this automatically without having me braking my little brain with math... ufff will add exta 20 event lines to my template i guess.. for 1 text that is gonna show on over 50 items that means will be around 1000 new event lines + an aditional 5 variants to each line of code per item that will be another 10 lines each so will be around 1500 more lines to add god.... hope my math is right oh and dident count the main text that shows the total currency and score that is again ....another 50 times ok must get cracking..... hope there is a simplistic way of doing this cause will add alot of events to the game im doing its not gonna lose frames cause i dont use every tick for displayng text but on command when smth is pressed that saves me more FPS but i guess in idle mode that thing will crack the game .... really need to implement this as a plugin or something.... sorry for calling on @Ashley , @Kiatric , @Tom but i tried to find a tutorial, plugin something there is none except the This tutorial https://www.scirra.com/tutorials/179/de ... in-a-float that i followed and kinda fixes my problem but i have to write 1500 event lines, so my simple almost eventless game will be not eventless anymore, in order to have this future without decimal points ....... sorry if im not being rational anymore in what im typing i dident sleept for 48 hrs almost ....
B
86
S
26
G
75
Posts: 1,439
Reputation: 47,803

### » Sun Feb 08, 2015 5:43 pm

Did you check the comments? Most of us don't use events, we use
Code: Select all
`floor(VARIABLE*100)/100`
which means that:

Input: 31265.3167
Output: 31265.31

Edit: I'm only not sure if using int or floor is best practice, or if it even matters.
B
62
S
20
G
51
Posts: 633
Reputation: 30,886

### » Sun Feb 08, 2015 6:40 pm

DatapawWolf wrote:Did you check the comments? Most of us don't use events, we use
Code: Select all
`floor(VARIABLE*100)/100`
which means that:

Input: 31265.3167
Output: 31265.31

Edit: I'm only not sure if using int or floor is best practice, or if it even matters.

thanks but i managed to get rid of the .decimal just when i use round or floor or int or str i just get the number 31265 now my next issue is when i try to show the text instead of 31265 as 31265/1000*"K" it should add a decimal point after 31 but not showing the 265 anymore because its just a split of the 1000
B
86
S
26
G
75
Posts: 1,439
Reputation: 47,803

### » Sun Feb 08, 2015 7:49 pm

In C# programming we call this little trick "casting". Casting happens when you change the type of variable. If it has a decimal point, the variable is a "float", if it is a whole number then it is an "integer".

You want to cast the Float into an integer. So there is an expression under system called int() , Anything in the "()" will be cast into an integer.

Other ways to cast are :str() for String, and float() for float.

int(random 1.2342,100.234234) will always return a whole number.
B
29
S
8
G
4
Posts: 767
Reputation: 5,985

Next