# How do I make my mathemathics formula work

Get help using Construct 2

### » Fri Mar 07, 2014 4:16 pm

I been trying and trying to get my formula to work but it just won't calculate the right way..
Its the formula for braking distance.

The formula: (int(Speed.Text)/3.6^2) / (2*Car.Car.Friction*9.81)

Every single time it has calculated the wrong number
For example if i put the "Speed.Text as 120 and Car.Car.Friction as 0.9 i will get 3.14 and thats not right at all. It should have been 27.9

Could anyone correct the code so it calculates right?
Last edited by Theredlambi on Fri Mar 07, 2014 6:00 pm, edited 3 times in total.
B
3
Posts: 4
Reputation: 210

### » Fri Mar 07, 2014 4:37 pm

I will not let you reach the sisters
Nature Forums
B
11
S
5
G
2
Posts: 496
Reputation: 2,306

### » Fri Mar 07, 2014 5:59 pm

The game is not finished just making the event sheet working
You do not have the required permissions to view the files attached to this post.
B
3
Posts: 4
Reputation: 210

### » Fri Mar 07, 2014 8:28 pm

I fixed the problem i just had to tweek the formula a bit so it would work,

The formula: (int(Speed.Text)/3.6)^2 /(2*9.81*Car.Car.Friction)
B
3
Posts: 4
Reputation: 210

### » Fri Mar 07, 2014 9:02 pm

This is because of order of operations
int(Speed.Text) / 3.6 ^ 2 will do 3.6 ^ 2 first because exponential has a higher priority

Then by using parenthesis (int(Speed.Text) / 3.6) ^ 2 will first do the division, then the exponential
B
87
S
22
G
15
Posts: 1,041
Reputation: 15,353