Light Sine??

Get help using Construct 2

Post » Fri Sep 06, 2013 2:17 am

I noticed in the debugger that Sine shows a lot of decimals, about 10 decimals.
is there a way to use only 1 or 2 decimals, thinking that that will be less CPU taxing?
thx



TL;DR: Is there a "Light Sine"?
B
12
S
3
G
1
Posts: 347
Reputation: 2,866

Post » Fri Sep 06, 2013 10:23 am

round(N * 100) / 100
for 2 decimals
1000 for 3 decimals
etc...

depends on when you do the rounding though... if you do it after the calculation it wont help :-)

But if you round and then use the number it should help.
B
20
S
6
G
4
Posts: 347
Reputation: 4,451

Post » Sat Sep 07, 2013 12:02 am

thanks a lot mr. elephant
@cvp
B
12
S
3
G
1
Posts: 347
Reputation: 2,866

Post » Sat Sep 07, 2013 1:40 am

@cvp
What's the right way?

I tried this:
1.- Output to Value
2.- Set "every tick", set sprite's Angle using the round(sprite.sine.value) formula

is that correct?
ghost2013-09-07 01:57:16
B
12
S
3
G
1
Posts: 347
Reputation: 2,866

Post » Sat Sep 07, 2013 2:02 am

CAPX:
capx
B
12
S
3
G
1
Posts: 347
Reputation: 2,866

Post » Sat Sep 07, 2013 4:14 am

It won't be less CPU taxing to display less decimals, it will just look neater.
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,699

Post » Sat Sep 07, 2013 4:23 am

[QUOTE=sqiddster] It won't be less CPU taxing to display less decimals, it will just look neater.[/QUOTE] This.

Plus: the conversion uses processor time, adding to the load.

It's just us humans who need numbers to be displayed with as less digits as possible - as long as we are not talking about our income
Image
B
24
S
8
G
10
Posts: 1,821
Reputation: 8,279

Post » Sat Sep 07, 2013 1:15 pm

rats
Im trying to find a solution 'cause I'm experiencing high cpu usage, check this:
http://www.scirra.com/forum/topic75537_post451602.html#451602ghost2013-09-07 20:27:57
B
12
S
3
G
1
Posts: 347
Reputation: 2,866

Post » Sat Sep 07, 2013 7:37 pm

as I said. it wont help you if you do the rounding after the calculation. It can only help you in cases where you use the rounded value alot afterwards.

E.g.

This:
roundedValue = round(12.123132165468798763213654) --> (roundedvalue = 12.12)

for i = 0 to i = 1000000
Do calculations on roundedValue


Would be faster then this:

for i = 0 to i = 1000000
Do calculations on 12.123132165468798763213654

But in your case (as the others mention) you will just add an extra calculation to the cpu cycle (the rounding)
B
20
S
6
G
4
Posts: 347
Reputation: 4,451


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 6 guests