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
57
S
35
G
16
Posts: 232
Reputation: 13,768

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
I don't check the forums much anymore, but I will receive an email for PMs.

"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
23
S
6
G
1
Posts: 1,419
Reputation: 4,857

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
57
S
35
G
16
Posts: 232
Reputation: 13,768

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
22
G
258
Posts: 3,791
Reputation: 143,198

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
76
S
31
G
27
Posts: 1,015
Reputation: 20,790

Post » Tue Jun 13, 2017 10:11 pm

@blackhornet
Thank you!

@Magistross
Awesome, Thanks!
B
57
S
35
G
16
Posts: 232
Reputation: 13,768


Return to How do I....?

Who is online

Users browsing this forum: dop2000 and 6 guests