How do I Show 1155 to 1.1K

Get help using Construct 2

Post » Tue Jun 13, 2017 10:03 am

Hello guys, how are you?
I try to show 1K, 1.1K etc etc but i think i miss something.

I use this:

Variable = 1155


round(variable/1000) & "K"
and the result is:
1K


I use this:
float(variable/1000) & "K"
and the result is:
1.155K



I want to remove "55" (in this example), means the 2 last numbers each time.
Can you help me? Thanks!
B
51
S
30
G
11
Posts: 226
Reputation: 10,572

Post » Tue Jun 13, 2017 4:45 pm

answer = round(variable / 10^2) * 10^2

or generically:

answer = round(variable / 10^places) * 10^places
https://www.ravenheart.ca/home
Company name changed to avoid Facebook-type shenanigans

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
22
S
6
G
1
Posts: 1,414
Reputation: 4,822

Post » Tue Jun 13, 2017 6:52 pm

@gumshoe2029

Thank you for your reply but i think something is wrong.
I test it with 1115 (variable) and gives me result: 1100

I talk about this:
round(variable / 10^2) * 10^2
B
51
S
30
G
11
Posts: 226
Reputation: 10,572

Post » Tue Jun 13, 2017 8:47 pm

Just divide by 1000 again.
(int(1155 / 10^2) * 10^2)/1000 & "K"
ImageImageImage
B
71
S
21
G
220
Posts: 3,646
Reputation: 123,721

Post » Tue Jun 13, 2017 8:57 pm

This is probably overkill but here's something I did back then : https://www.dropbox.com/s/ry1ry2wbxmycd ... .capx?dl=0
B
67
S
27
G
24
Posts: 968
Reputation: 18,571

Post » Tue Jun 13, 2017 10:11 pm

@blackhornet
Thank you!

@Magistross
Awesome, Thanks!
B
51
S
30
G
11
Posts: 226
Reputation: 10,572


Return to How do I....?

Who is online

Users browsing this forum: Zav and 6 guests