如何将Int转换为显示美元金额?我所拥有的数字集没有小数点,例如1234.45。
因此,如何将Int 175533000转换为$175,533,000而不是$175,533,000.00?
发布于 2022-07-18 19:43:15
一种可能的方法是在formatted 15 / macOS 12中引入了非常通用的iOS API。
let value = 175533000
let formatted = value.formatted(.currency(code: "usd")
.precision(.fractionLength(0))
.locale(.init(identifier: "en_US")))
print(formatted) https://stackoverflow.com/questions/73027567
复制相似问题