• js 精确计算求和


    accAdd(arg1, arg2) {
                    var r1 = this.deal(arg1);
                    var r2 = this.deal(arg2);
                    var m = Math.pow(10, Math.max(r1, r2))
                    return (this.accMul(arg1, m) + this.accMul(arg2, m)) / m
                },
                accSub(arg1, arg2) {
                    var r1 = this.deal(arg1);
                    var r2 = this.deal(arg2);
                    var m = Math.pow(10, Math.max(r1, r2))
                    return (this.accMul(arg1, m) - this.accMul(arg2, m)) / m
                },
                accMul(arg1, arg2) {
                    var m = 0;
                    m += this.deal(arg1);
                    m += this.deal(arg2);
                    var r1 = Number(arg1.toString().replace(".", ""));
                    var r2 = Number(arg2.toString().replace(".", ""));
                    return (r1 * r2) / Math.pow(10, m)
                },
                deal(arg) {
                    var t = 0;
                    try {
                        t = arg.toString().split(".")[1].length
                    } catch (e) {}
                    return t;
                },
    changchecked(item, index) {
                    let obj = {
                        idExamFeeItem: item.idExamFeeItem
                    }
                    this.orderInfo.itemInfoList.push(obj)
                    item.checked = !item.checked
                    if (item.checked) {
                        this.price = this.accAdd(this.price, item.feePrice)
                        console.log(this.orderInfo.itemInfoList)
    
                    } else {
                        //取消选择
                        this.price = this.accSub(this.price, item.feePrice)
                        this.orderInfo.itemInfoList = this.orderInfo.itemInfoList.filter((item) => {
                        return !(JSON.stringify(item)==JSON.stringify(obj))
                              
                        })
                        console.log(this.orderInfo.itemInfoList)
                    }
    
    
                },
  • 相关阅读:
    1113. Integer Set Partition (25)
    1110. Complete Binary Tree (25)
    1109. Group Photo (25)
    Bender Problem
    格子中输出
    牌型种数
    移动距离
    QQ帐户的申请与登陆(25 分)
    词频统计
    基于HTTP的直播点播HLS
  • 原文地址:https://www.cnblogs.com/xzhce/p/13731028.html
Copyright © 2020-2023  润新知