How do I round a number to multiple of another number?

Get help using Construct 2

Post » Thu Jun 16, 2016 2:23 am

Can someone tell me if this is correct?
If TileXValue = 12

TileXValue >= 0 ? (TileXValue - TileXValue%64) : (TileXValue - TileXValue%64) -64
12 >= 0 Then (12 - 4) Else (12 - 4) - 64
12 >= 0 Then 8 Else -56

So the answer would be 8?
B
68
S
37
G
13
Posts: 242
Reputation: 12,787

Post » Thu Jun 16, 2016 3:09 am

@Unconnected

12 % 64 = 12

because 12 goes into 64 zero times with 12 left over.

so, you would have 12>=0 Then (12 - 12) else (12 - 12) - 64

which is 0 or -64

0 is the answer.
B
99
S
35
G
20
Posts: 438
Reputation: 17,910

Post » Thu Jun 16, 2016 3:29 am

I did the math wrong then...
What I did was put 12 into 64 five times (60) with 4 left over.
I thought my answers seemed off though.

Basically it subtracts 64 from TileXValue until it can't anymore and what is left is the answer?

So it means...
64 will go into 12 Zero times, since there is 12 left over the answer is 12.
so then
64 will go into 68 One Time with 4 left over. So the answer would be 4.

Thanks for your time.
B
68
S
37
G
13
Posts: 242
Reputation: 12,787

Previous

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 27 guests