I'm looking for some algorithm to "smart" round small numbers. For example:
Let's have array with values:
0: 4.0236180709235
1: 4.02462309509067
2: 4.02412058061092
.
.
17: 4.01599998414516
18: 4.01599998414516
19: 4.01949998319149
And if I look at this array i can se that this numbers are mostly different in .000 position so it should return -> 3 (that I then use in => .toFixed(3))
Probably I should calc the difference between max and min value of array and from that get that best number for decimal places.
Or loop that array...
Second example:
0: 4.0236180709235
1: 4.01462309509067
2: 4.03412058061092
.
.
17: 4.05599998414516
18: 4.06599998414516
19: 4.09949998319149
There I can see that decimal number for round should be 2.
Thanks!