Round Issue in swift

后端 未结 3 454
無奈伤痛
無奈伤痛 2021-01-07 14:58

I have this Info.

let params2: [String: AnyObject] = [
    \"app_token\": myapptoken,
    \"member_access_token\": accessToken!,
    \"pay_process\": 0,
             


        
3条回答
  •  孤独总比滥情好
    2021-01-07 15:07

    The problem lies within the numeric precission, simply put, some numbers cannot be defined as a Double without losing precision.

    Instead you should use NSDecimalNumber:

    let num = NSDecimalNumber(string: "9.87")
    

提交回复
热议问题