Helper function to perform rounding of numbers when working with mongoDB Aggregation Framework.
npm install mongo-round
var round = ;
To zero decimal places:
To two decimal places:
To cents and from cents - saves from rounding errors for armithmetic operations on financial data:
Note that for negative numbers rounding is done using absolute values, which is fitting for financial data:
round(-0.5) will give -1