How to round values when performing calculations? (Money, %)

Just started using Construct 2? Post your questions here

Post » Fri Apr 10, 2015 3:25 pm

I'm creating a simple thing that calculates values based around money. It works perfectly but sometimes you'll get a thing where it's $33/$99 or so, and makes it a third of the value, spitting out things like $33.3333333333 or $66.6666666666667 etc. Same thing with percentages.

How would I round these values up so it only has two decimal places? And in the case of percentages, no decimal places?
B
20
S
5
Posts: 108
Reputation: 1,473

Post » Fri Apr 10, 2015 3:29 pm

Round(Value/100)*100 will return:
For value being 33.33333333333, it will return 33.33
for 66.666666666, it will return 66.67
for 10.50, it will return 10.5

Round(value) will returnthe value rounded to the nearest integer.
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
48
S
21
G
18
Posts: 2,113
Reputation: 16,875


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests