E. Tess - 3 years ago 124

Swift Question

This is a example equation which I want to be solved:

`let equation = (5-2) * (10-5) / (4-2) * (10-5)`

print (equation)

//35

The result which is printed is 35. But the right result would be 1,5. Whats wrong?

Recommended for you: Get network issues from **WhatsUp Gold**. **Not end users.**

Answer Source

This should work:

```
let numerator: Double = (5-2) * (10-5)
let denumerator: Double = (4-2) * (10-5)
```

Fist you calculate the numerator and denumerator. And finally the result:

```
print(result)
let result: Double = numerator/denumerator
//1.5
```

Recommended from our users: **Dynamic Network Monitoring from WhatsUp Gold from IPSwitch**. ** Free Download**