# expression needed to round number

Get help using Construct 2

### » Tue Feb 16, 2016 9:20 am

how do i round number 6,879 to 6,88 ?

i know only that expressions:
floor
round
ciel (dont work)
is any other to use??
B
119
S
32
G
51
Posts: 1,896
Reputation: 38,574

### » Tue Feb 16, 2016 9:41 am

Maybe the answer is to easy:

x= 6,879

round(x*100)/100
B
26
S
3
G
1
Posts: 480
Reputation: 2,290

### » Tue Feb 16, 2016 9:49 am

The actual expression is spelled "Ceil()" and it will round to the upper integer.
In doubts always refer to the system expressions manual article.

New to Construct ? Where to start

Please attach a capx to any help request or bug report !
Moderator
B
306
S
126
G
99
Posts: 7,381
Reputation: 73,838

### » Tue Feb 16, 2016 9:58 am

@Asmodean that works perfecct
B
119
S
32
G
51
Posts: 1,896
Reputation: 38,574

### » Tue Feb 16, 2016 10:00 am

@Kyatric and is @ Asmodean are both correct.

Ceil() is great for rounding up integers while floor() is great to round down integers.

Take your value x and use (floor(x*100)/100), granted round will do the same in this example; but floor is better for if the number has lots of decimals.
Using R248 for all examples
B
70
S
21
G
6
Posts: 382
Reputation: 9,812

### » Tue Feb 16, 2016 10:09 am

@emodaeden: Indeed floor() has an impact on the number of decimals.
But it also impacts the result, whether the last decimal is greater than 5 or not, when using "floor" the returned number will always be rounded down, whereas "round" allows to have a distribution in both direction (down if the last decimal is less than 5, up if it is 5 or more).

To impact on the number of decimals you want, modify the value "100" to bigger, depending on the decimals you need.
New to Construct ? Where to start

Please attach a capx to any help request or bug report !
Moderator
B
306
S
126
G
99
Posts: 7,381
Reputation: 73,838