Rounding Decimals

Get help using Construct 2

Post » Tue Jul 08, 2014 5:58 am

I'm aware of the current rounding math expressions (round() and ceil()), which round to the whole number. How would I go about rounding to the nearest decimal, though? I'm wanting to do a stop-watch timer on the HUD with the total accumulated dt rounded to the nearest tenth of a second. I tried to create a second global variable to account for the fractions of a second, but that didn't work out...actually, it was worse. LOL

Any suggestions? Thank you!
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
136
S
22
G
8
Posts: 770
Reputation: 14,714

Post » Tue Jul 08, 2014 6:29 am

round(var*10)/10 should work for rounding to the nearest tenth.
B
91
S
31
G
103
Posts: 5,238
Reputation: 67,762

Post » Tue Jul 08, 2014 5:38 pm

As usual, rock. Thanks! :D
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
136
S
22
G
8
Posts: 770
Reputation: 14,714


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 1 guest