You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

求助:NSDecimalNumber转intValue/int64Value返回0致钱包余额清零

NSDecimalNumber 整数取值异常问题

输入图片描述

为何以下取值结果不符合预期:

  • NSDecimalNumber(string:"2175613.285964774433431797660").intValue = 0
  • NSDecimalNumber(string:"2175613.285964774433431797660").int32Value = 2175613
  • NSDecimalNumber(string:"2175613.285964774433431797660").int64Value = 0

恳请各位帮忙解答!

环境信息

  • Apple M1
  • Mac OS Ventura 13.0
  • Xcode 14.1

代码示例

let a = NSDecimalNumber(string: "2175613.285964774433431797660188672").intValue
// a == 0 结果为真 

该问题已导致用户钱包余额直接清零,造成严重影响。


内容的提问来源于stack exchange,提问作者hida-cui

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.16 14:17:09