panlei
2019-08-02 b908f300ec1b3ed87b8776ff0a3f5aae2b1bbdc9
数值精度保留
1个文件已修改
10 ■■■■ 已修改文件
ruleserver/readyDataForRule.go 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruleserver/readyDataForRule.go
@@ -94,11 +94,11 @@
    return v
}
func Decimal(value float32) float64 {
    value1, _ := strconv.ParseFloat(fmt.Sprintf("%.4f", float64(value)), 64)
    logger.Info("初步保留四位成str:",value1)
    value1, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", float64(value)), 64)
    logger.Info("初步保留两位成str:",value1)
    n10 := math.Pow10(4)
    value2 := math.Trunc((value1+0.5/n10)*n10) / n10
    logger.Info("初步保留四位成str::::",value2)
    logger.Info("初步保留两位成str::::",value2)
    return value2
}
// 取出某个时间规则的第几天的规则段集合
@@ -186,8 +186,8 @@
            if err != nil || len(table) == 0 {
                logger.Error("根据id查询底库信息出错!", err, "--返回值长度为:", len(table))
            }
            logger.Debug("看看这个base的对比值是多少:", Decimal(m[baseinfo.Id]) * 100)
            base := BaseInfo{TableId: baseinfo.TableId, TableName: table[0].TableName, BwType: table[0].BwType, CompareScore: Decimal(m[baseinfo.Id]) * 100, PersonId: baseinfo.Id, PersonName: baseinfo.PersonName, PersonPicUrl: baseinfo.PersonPicUrl, PhoneNum: baseinfo.PhoneNum, Sex: baseinfo.Sex, IdCard: baseinfo.IdCard, MonitorLevel: baseinfo.MonitorLevel, Content: baseinfo.Reserved}
            logger.Debug("看看这个base的对比值是多少:", Decimal(m[baseinfo.Id] * 100))
            base := BaseInfo{TableId: baseinfo.TableId, TableName: table[0].TableName, BwType: table[0].BwType, CompareScore: Decimal(m[baseinfo.Id] * 100), PersonId: baseinfo.Id, PersonName: baseinfo.PersonName, PersonPicUrl: baseinfo.PersonPicUrl, PhoneNum: baseinfo.PhoneNum, Sex: baseinfo.Sex, IdCard: baseinfo.IdCard, MonitorLevel: baseinfo.MonitorLevel, Content: baseinfo.Reserved}
            //os.Exit(1)
            arg.Liker = append(arg.Liker, &base)
        }