One place after zero.

Discussion and feedback on Construct 2

Post » Wed Oct 19, 2016 1:34 pm

How do I get a number to always show one place after the zero, even if it's going to be .0?

I want a percentile text where it will show values like 10.3%, 18.8%, 50.0% etc. but I don't know how to get it to display this when the digit after the decimal point is 0.
B
45
S
13
G
1
Posts: 236
Reputation: 4,010

Post » Wed Oct 19, 2016 2:11 pm

You might be looking for something like that:

example_variable=0.2334
Set text: left(example_variable*100,4)&"%"
B
137
S
33
G
17
Posts: 1,560
Reputation: 20,797

Post » Wed Oct 19, 2016 6:33 pm

Didn't work when the value was something like 5%. However, I took your idea and modified it where it does work, because I didn't think to use things like left.

floor(percentile * 100) & "." & right(str(floor(percentile * 1000)), 1) & "%"

Thanks for the nudge in the right direction.
B
45
S
13
G
1
Posts: 236
Reputation: 4,010

Post » Wed Oct 19, 2016 6:58 pm

corlenbelspar wrote:Thanks for the nudge in the right direction.

You're welcome, and I'm sorry for not thinking about the one digit percentages. It just slipped through my mind.
B
137
S
33
G
17
Posts: 1,560
Reputation: 20,797


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 6 guests