# How do I get this format: 12.33%

Just started using Construct 2? Post your questions here

### » Mon Nov 07, 2016 12:53 pm

I'm doing a chart with 6 bars and I need to get this type of format: 12.33% besides that the sum of all the results must be 100%

Expression I'm using: round(intResult/totalPoints)*100&"%"

If the intResult is equal 12 and the totalPoints is 115, I'm getting 10% instead of 10.43%

I also need to know how to detect the higher one and a tie.
B
4
S
2
Posts: 153
Reputation: 908

### » Mon Nov 07, 2016 1:13 pm

if intResult = 12 and totalPoints = 115,
round(intResult/totalPoints)*100&"%" should return "0 %"
round(intResult/totalPoints*100)&"%" should return "10%"
round(intResult/totalPoints*10000)/100&"%" should return "10.43%"
Last edited by MadSpy on Mon Nov 07, 2016 1:15 pm, edited 1 time in total.
B
28
S
17
G
160
Posts: 894
Reputation: 83,261

### » Mon Nov 07, 2016 1:14 pm

because you added round = which takes the nearest to the higher value or lower, and cuts it out, for example, if you have round(104.50) the result will be 104 ... if it will be round(104.51) the result its going to be 105 because it passed the half value.

try using float

Code: Select all
`float(x)Convert the integer or text x to a float (fractional number). If x is text, non-numeric characters are allowed after the number, but not before. For example float("3.1xx") returns 3.1, but float("xx3.1") returns 0.`

Code: Select all
`round(x) Round x to the nearest whole number e.g. round(5.6) = 6`

check manualfor more expressions
B
86
S
26
G
75
Posts: 1,440
Reputation: 47,810

### » Mon Nov 07, 2016 10:59 pm

Thank you guys.

@MadSpy: It worked very well.
B
4
S
2
Posts: 153
Reputation: 908

Return to Beginner's Questions

### Who is online

Users browsing this forum: No registered users and 1 guest