Computing an array's average
No. 222
|
Q: |
We consider a method The intention is rounding e.g.
Hint: Read the |
|
A: |
There are two issues here:
We end up with cutting off again. Enforcing
return Math.round(10.0 * sum / values.length) / 10.0; Overflow errors are possible as well: Using |
