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
142
S
24
G
8
Posts: 793
Reputation: 15,157

Post » Tue Jul 08, 2014 6:29 am

round(var*10)/10 should work for rounding to the nearest tenth.
B
94
S
33
G
117
Posts: 5,387
Reputation: 75,335

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
142
S
24
G
8
Posts: 793
Reputation: 15,157


Return to How do I....?

Who is online

Users browsing this forum: dop2000, Maako and 9 guests