# how do I round up to the nearest whole number?

Get help using Construct 2

### » Fri Nov 01, 2013 1:23 pm

Hello everyone! I have a question, how do I round up a number to the nearest whole number

[/IMG]

How do I round it up to the nearest whole number like 6999? Thanks in advance! (My first post)
B
16
S
6
G
2
Posts: 42
Reputation: 2,564

### » Fri Nov 01, 2013 1:56 pm

ceil(x)
B
71
S
22
G
288
Posts: 3,860
Reputation: 158,426

### » Fri Nov 01, 2013 2:12 pm

"round(x)" also seems to work fine.

Update.
Apparently i can't read very well. >_>
I tend to accidentally a couple of words every now and then...
My most sincere apologies, gentlemen.Stiivais2013-11-01 17:09:20
B
10
S
1
Posts: 163
Reputation: 1,436

### » Fri Nov 01, 2013 2:20 pm

@Stiivais The OP was asking for rounding up. Yes round(x) would work, but if the decimal is below 5 it will round down. ceil(x) will always round up, and floor(x) will always round down.
B
48
S
15
G
8
Posts: 603
Reputation: 8,766

### » Fri Nov 01, 2013 2:23 pm

@Stiivais
Because topicstarter was asking for rounding up, ceil() is the right answer.

for rounding up one uses : ceil()
for rounding down one uses : floor()
for rounding up or down one uses : round()

ninjaaad by @EncryptedCowLittleStain2013-11-01 14:24:01
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

### » Sat Nov 02, 2013 1:45 am

Thanks everyone for your replies, but I still don't get it.

Here's my code: distance(Slingshot.X, Slingshot.Y, snail.X, snail.Y)

I'am trying to make it display the distance between the catapult and the snail, but I don't have any idea where to insert the formula like the ceil(), floor() ect. Thanks!
B
16
S
6
G
2
Posts: 42
Reputation: 2,564

### » Sat Nov 02, 2013 2:39 am

ceil(distance(Slingshot.X, Slingshot.Y, snail.X, snail.Y))
B
71
S
22
G
288
Posts: 3,860
Reputation: 158,426

### » Sat Nov 02, 2013 3:37 am

Got it! Thanks everyone!
B
16
S
6
G
2
Posts: 42
Reputation: 2,564

### » Sat Nov 02, 2013 3:39 am

One more question: do I create a elastic band that connect the slingshot to the snail?
B
16
S
6
G
2
Posts: 42
Reputation: 2,564

### » Sat Nov 02, 2013 5:36 am

B
71
S
22
G
288
Posts: 3,860
Reputation: 158,426

Next