const  Decimal = require('../miniprogram_npm/decimal.js/index');
module.exports={
//加
add(arr){
  var total = 0
  for(var i = 0;i<arr.length;i++){
    var num = arr[i]
    total = Decimal(total).add(Decimal(num)).toNumber()
  }
  return total
},
//减
sub(arr){
  var total = arr[0]
  for(var i = 1;i<arr.length;i++){
    var num = arr[i]
    total = Decimal(total).sub(Decimal(num)).toNumber()
  }
  return total
},
//乘
mul(arr){
  var total = 1
  for(var i = 0;i<arr.length;i++){
    var num = arr[i]
    total = Decimal(total).mul(Decimal(num)).toNumber()
  }
  return total
},
//除
div:(arr)=>{
  var total = arr[0]
  for(var i = 1;i<arr.length;i++){
    var num = arr[i]
    total = Decimal(total).div(Decimal(num)).toNumber()
  }
  return total
}
}
