Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

商品*3(购买数量)=1块钱,拆分成三个订单
那么每个商品对应的订单金额就是0.33(程序四舍五入)
我现在把三个订单的金额加起来=0.99,这就少了0.01

我现在是和钱包一起用的,有可能出现这种情况
3个商品3块钱,我用了2块钱包


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
300 views
Welcome To Ask or Share your Answers For Others

1 Answer

你需要一个求平均数的函数,因为 10/3 除法不尽的,我处理为最后一个数用来做微调
image


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...