how do I round up to the nearest whole number?

Get help using Construct 2

Post » 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,554

Post » Fri Nov 01, 2013 1:56 pm

ceil(x)
ImageImageImage
B
71
S
21
G
220
Posts: 3,648
Reputation: 123,725

Post » 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

Post » 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
46
S
14
G
7
Posts: 603
Reputation: 8,096

Post » 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

Post » 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,554

Post » Sat Nov 02, 2013 2:39 am

ceil(distance(Slingshot.X, Slingshot.Y, snail.X, snail.Y))
ImageImageImage
B
71
S
21
G
220
Posts: 3,648
Reputation: 123,725

Post » Sat Nov 02, 2013 3:37 am

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

Post » 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,554

Post » Sat Nov 02, 2013 5:36 am

ImageImageImage
B
71
S
21
G
220
Posts: 3,648
Reputation: 123,725

Next

Return to How do I....?

Who is online

Users browsing this forum: Apollo14, ivanski1983, KTML5 and 4 guests