Number of decimals i function

This is the second thread today that this has been discussed (Problems using '.toFixed()'). It is generally best not to do this until you are about to display it, assuming that the reason you want to limit it is for display purposes. Don't throw away accuracy until the very last moment. Often the widget you are using for display has the ability to show numbers to a given number of decimals. See the other thread for how to use angular filters in dashboard nodes to do this.
If you really do need to truncate in a function then look at the .toFixed() function as used in that thread.