digit to integer

Discussion and feedback on Construct 2

Post » Wed Apr 17, 2013 12:00 pm

Hi All,
can u help me how to convert digit to integer
example :
2.333 will be converted to 2
2.666 will be converted to 3

so digit will be converted to Closest integer ;

thx
B
5
S
2
Posts: 49
Reputation: 873

Post » Wed Apr 17, 2013 12:03 pm

use expression int(string or variable)
B
99
S
35
G
29
Posts: 3,139
Reputation: 28,421

Post » Wed Apr 17, 2013 12:47 pm

also, if you want only the rounded down valor, use floor, and ceil to the rounded up valor.

https://www.scirra.com/manual/126/system-expressions
Image
B
108
S
24
G
18
Posts: 1,373
Reputation: 22,824

Post » Wed Apr 17, 2013 2:33 pm

thanks Friends
B
5
S
2
Posts: 49
Reputation: 873

Post » Wed Apr 17, 2013 2:34 pm

@Joannesalfa - int(number) will round down, so 2.666 will give 2 instead of 3. Use the floor(number) expression instead.
Scirra Founder
B
399
S
236
G
89
Posts: 24,524
Reputation: 195,380


Return to Construct 2 General

Who is online

Users browsing this forum: NECRONOMICRON, Yahoo [Bot] and 9 guests